Fix get_all_hardlinks logging/hinting

This commit is contained in:
Darryl Nixon 2023-07-16 11:54:12 -07:00
parent 67570a4368
commit 5fcf743b2b

View file

@ -14,22 +14,6 @@ from .fileops import mount_to_fs_handler
from .logs import logger
async def get_all_hardlinks(paths: Set[Path]) -> None:
for path in paths:
if isinstance(path, ShredFile):
logger.info(f"Getting hardlinks for {path}")
hardlink_count = 0
path.hardlinks = set()
async for link in path.fs_handler.get_hardlinks(path.absolute_path):
hardlink_count += 1
path.hardlinks.add(link)
logger.info(f"Found hardlink: {link}")
logger.info(f"Found {hardlink_count} hardlinks for {path.absolute_path}")
if isinstance(path, ShredDir):
path.contents = await get_all_hardlinks(path.contents)
return paths
class AsyncObject(object):
async def __new__(cls, *a, **kw):
instance = super().__new__(cls)
@ -160,3 +144,19 @@ class ShredFile(AsyncObject):
def __hash__(self) -> int:
return hash(self.absolute_path)
async def get_all_hardlinks(paths: Set[Union[ShredFile, ShredDir]]) -> None:
for path in paths:
if isinstance(path, ShredFile):
logger.info(f"Getting hardlinks for {path.absolute_path}")
hardlink_count = 0
path.hardlinks = set()
async for link in path.fs_handler.get_hardlinks(path.absolute_path):
hardlink_count += 1
path.hardlinks.add(link)
logger.info(f"Found hardlink: {link}")
logger.info(f"Found {hardlink_count} hardlinks for {path.absolute_path.name}")
if isinstance(path, ShredDir):
path.contents = await get_all_hardlinks(path.contents)
return paths