This commit is contained in:
Darryl Nixon 2023-07-16 16:15:45 -07:00
parent 9e92baba1c
commit 23a0e255b2

View file

@ -66,6 +66,7 @@ async def main(job: argparse.Namespace) -> bool:
async def check_inode_and_unlink(item, inodes): async def check_inode_and_unlink(item, inodes):
async with semaphore: async with semaphore:
try:
stat = await item.stat() stat = await item.stat()
if stat.st_ino in inodes: if stat.st_ino in inodes:
log_buf = f"Deleting hardlink: {item.path}" log_buf = f"Deleting hardlink: {item.path}"
@ -73,6 +74,8 @@ async def main(job: argparse.Namespace) -> bool:
log_buf = "DRY RUN " + log_buf log_buf = "DRY RUN " + log_buf
await item.path.unlink() await item.path.unlink()
logger.info(log_buf) logger.info(log_buf)
except FileNotFoundError:
pass
for mount_point, inodes in inodes_in_mount_points.items(): for mount_point, inodes in inodes_in_mount_points.items():
# checking for . and .. should not be neccessary w/ rglob # 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: if str(item) in IGNORE_GLOBAL:
continue continue
async for subitem in mount_bound_rglob(item, mount_point, "*", job.ignoredir): 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)) tasks.append(check_inode_and_unlink(subitem, inodes))
else: else:
tasks.append(check_inode_and_unlink(item, inodes)) tasks.append(check_inode_and_unlink(item, inodes))
@ -97,6 +107,6 @@ async def main(job: argparse.Namespace) -> bool:
for task in done: for task in done:
e = task.exception() e = task.exception()
if e: if e:
logger.warning(f"Unable to unlink hardlink: {e}") logger.trace(f"Error during find: {e}")
logger.info("Done") logger.info("Done")