mirror of
https://github.com/DarrylNixon/melamine.git
synced 2024-04-22 06:27:20 -07:00
merge
This commit is contained in:
parent
9e92baba1c
commit
23a0e255b2
1 changed files with 18 additions and 8 deletions
|
@ -66,13 +66,16 @@ 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:
|
||||||
stat = await item.stat()
|
try:
|
||||||
if stat.st_ino in inodes:
|
stat = await item.stat()
|
||||||
log_buf = f"Deleting hardlink: {item.path}"
|
if stat.st_ino in inodes:
|
||||||
if not job.dryrun:
|
log_buf = f"Deleting hardlink: {item.path}"
|
||||||
log_buf = "DRY RUN " + log_buf
|
if not job.dryrun:
|
||||||
await item.path.unlink()
|
log_buf = "DRY RUN " + log_buf
|
||||||
logger.info(log_buf)
|
await item.path.unlink()
|
||||||
|
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")
|
||||||
|
|
Loading…
Reference in a new issue