Trying out aiopath

This commit is contained in:
Darryl Nixon 2023-07-16 12:59:30 -07:00
parent e04d86d3cb
commit cd91b960dd
6 changed files with 29 additions and 28 deletions

View file

@ -1,8 +1,6 @@
import argparse
from collections import defaultdict
import aiofiles
from .classes import get_all_hardlinks
from .classes import ShredDir
from .classes import ShredFile
@ -41,14 +39,14 @@ async def main(job: argparse.Namespace) -> bool:
inodes_in_mount_points[path.mount_point].add(path.inode)
for mount_point, inodes in inodes_in_mount_points.items():
async for item in aiofiles.os.scandir(mount_point):
async for item in mount_point.rglob("*"):
if item.name == "." or item.name == "..":
continue
if item.stat().st_ino in inodes:
log_buf = f"Deleting hardlink: {item.path}"
if not job.dryrun:
log_buf = "DRY RUN " + log_buf
await aiofiles.os.unlink(item.path)
await item.path.unlink()
logger.info(log_buf)
# Shred all physical files including hardlinks