From 23a0e255b24e3339e9018c5372311201f4cb03c3 Mon Sep 17 00:00:00 2001 From: Darryl Nixon Date: Sun, 16 Jul 2023 16:15:45 -0700 Subject: [PATCH] merge --- melamine/shred.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/melamine/shred.py b/melamine/shred.py index 00cf4c5..8e42678 100644 --- a/melamine/shred.py +++ b/melamine/shred.py @@ -66,13 +66,16 @@ async def main(job: argparse.Namespace) -> bool: async def check_inode_and_unlink(item, inodes): async with semaphore: - stat = await item.stat() - if stat.st_ino in inodes: - log_buf = f"Deleting hardlink: {item.path}" - if not job.dryrun: - log_buf = "DRY RUN " + log_buf - await item.path.unlink() - logger.info(log_buf) + try: + stat = await item.stat() + if stat.st_ino in inodes: + log_buf = f"Deleting hardlink: {item.path}" + if not job.dryrun: + log_buf = "DRY RUN " + log_buf + await item.path.unlink() + logger.info(log_buf) + except FileNotFoundError: + pass for mount_point, inodes in inodes_in_mount_points.items(): # checking for . and .. should not be neccessary w/ rglob @@ -86,6 +89,13 @@ async def main(job: argparse.Namespace) -> bool: if str(item) in IGNORE_GLOBAL: continue async for subitem in mount_bound_rglob(item, mount_point, "*", job.ignoredir): + abso = await item.absolute() + if str(abso).startswith("/home/parallels/hardlinks"): + logger.warning(f"Scanning {abso}") + logger.warning(f"inodes are {inodes}") + no = await item.stat() + logger.warning(f"{abso} inode is {no.st_ino}") + logger.warning(f"is {abso} in inodes? {str(bool(no.st_ino in inodes))}") tasks.append(check_inode_and_unlink(subitem, inodes)) else: tasks.append(check_inode_and_unlink(item, inodes)) @@ -97,6 +107,6 @@ async def main(job: argparse.Namespace) -> bool: for task in done: e = task.exception() if e: - logger.warning(f"Unable to unlink hardlink: {e}") + logger.trace(f"Error during find: {e}") logger.info("Done")