mirror of
https://github.com/DarrylNixon/melamine.git
synced 2024-04-22 06:27:20 -07:00
Fix get_all_hardlinks logging/hinting
This commit is contained in:
parent
67570a4368
commit
5fcf743b2b
1 changed files with 16 additions and 16 deletions
|
@ -14,22 +14,6 @@ from .fileops import mount_to_fs_handler
|
||||||
from .logs import logger
|
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):
|
class AsyncObject(object):
|
||||||
async def __new__(cls, *a, **kw):
|
async def __new__(cls, *a, **kw):
|
||||||
instance = super().__new__(cls)
|
instance = super().__new__(cls)
|
||||||
|
@ -160,3 +144,19 @@ class ShredFile(AsyncObject):
|
||||||
|
|
||||||
def __hash__(self) -> int:
|
def __hash__(self) -> int:
|
||||||
return hash(self.absolute_path)
|
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
|
||||||
|
|
Loading…
Reference in a new issue