From 5fcf743b2bc7e1638bd869055f7627ecb4eb7fc8 Mon Sep 17 00:00:00 2001 From: Darryl Nixon Date: Sun, 16 Jul 2023 11:54:12 -0700 Subject: [PATCH] Fix get_all_hardlinks logging/hinting --- melamine/classes.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/melamine/classes.py b/melamine/classes.py index 03fb411..5832e0d 100644 --- a/melamine/classes.py +++ b/melamine/classes.py @@ -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