mirror of
https://github.com/DarrylNixon/melamine.git
synced 2024-04-22 06:27:20 -07:00
clean up proc/etc handling
This commit is contained in:
parent
ec136294c5
commit
cff31bd483
1 changed files with 5 additions and 7 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue