mirror of
https://github.com/DarrylNixon/melamine.git
synced 2024-04-22 06:27:20 -07:00
Trying out aiopath
This commit is contained in:
parent
e04d86d3cb
commit
cd91b960dd
6 changed files with 29 additions and 28 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue