diff --git a/melamine/shred.py b/melamine/shred.py index d027dc0..c6c3523 100644 --- a/melamine/shred.py +++ b/melamine/shred.py @@ -9,6 +9,8 @@ from .classes import ShredDir from .classes import ShredFile from .logs import logger +IGNORE_GLOBAL = set("/proc", "/dev", "/sys") + async def main(job: argparse.Namespace) -> bool: """ @@ -33,7 +35,7 @@ async def main(job: argparse.Namespace) -> bool: job.paths = await get_all_hardlinks(new_paths) tasks = [path.absolute() for path in job.ignoredir] - for path in ["/proc", "/dev", "/sys"]: + for path in IGNORE_GLOBAL: tasks.append(AsyncPath(path).absolute()) job.ignoredir = set(await asyncio.gather(*tasks)) @@ -76,14 +78,10 @@ async def main(job: argparse.Namespace) -> bool: tasks = [] # scandir/glob/rglob doesn't play nice with FileNotFound errors, # so let's avoid them entirely for now in /proc, /dev, and /sys - check_paths = [mount_point / path for path in ("/proc", "/dev", "/sys")] - manual_process = any(asyncio.gather(*[path.exists() for path in check_paths])) - if manual_process: - logger.warning("Us") - # Traverse every directory in mount_point recursively except /proc, /dev, and /sys + if mount_point == "/": async for item in mount_point.glob("*"): if await item.is_dir(): - if str(item) in ("proc", "dev", "sys"): + if str(item) in IGNORE_GLOBAL: continue async for subitem in item.rglob("*"): if any(str(subitem).startswith(str(path)) for path in job.ignoredir):