mirror of
https://github.com/DarrylNixon/melamine.git
synced 2024-04-22 06:27:20 -07:00
proc is a cruel mistress
This commit is contained in:
parent
b1e9053bb4
commit
4215f4dd2c
1 changed files with 21 additions and 5 deletions
|
@ -33,7 +33,8 @@ async def main(job: argparse.Namespace) -> bool:
|
|||
job.paths = await get_all_hardlinks(new_paths)
|
||||
|
||||
tasks = [path.absolute() for path in job.ignoredir]
|
||||
tasks.append(AsyncPath("/proc").absolute())
|
||||
for path in ["/proc", "/dev", "/sys"]:
|
||||
tasks.append(AsyncPath(path).absolute())
|
||||
job.ignoredir = set(await asyncio.gather(*tasks))
|
||||
|
||||
# Shred all physical files including hardlinks
|
||||
|
@ -72,6 +73,21 @@ async def main(job: argparse.Namespace) -> bool:
|
|||
for mount_point, inodes in inodes_in_mount_points.items():
|
||||
# checking for . and .. should not be neccessary w/ rglob
|
||||
tasks = []
|
||||
# scandir/glob/rglob doesn't play nice with FileNotFound errors,
|
||||
# so let's avoid them entirely for now in /proc, /dev, and /sys
|
||||
if any((mount_point / path).exists() for path in ("/proc", "/dev", "/sys")):
|
||||
# Traverse every directory in mount_point recursively except /proc, /dev, and /sys
|
||||
async for item in mount_point.glob("*"):
|
||||
if await item.is_dir():
|
||||
if str(item) in ("proc", "dev", "sys"):
|
||||
continue
|
||||
async for subitem in item.rglob("*"):
|
||||
if any(str(subitem).startswith(str(path)) for path in job.ignoredir):
|
||||
continue
|
||||
tasks.append(check_inode_and_unlink(subitem, inodes))
|
||||
else:
|
||||
tasks.append(check_inode_and_unlink(item, inodes))
|
||||
else:
|
||||
async for item in mount_point.rglob("*"):
|
||||
if any(str(item).startswith(str(path)) for path in job.ignoredir):
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue