mirror of
https://github.com/DarrylNixon/melamine.git
synced 2024-04-22 06:27:20 -07:00
Remove directories, too
This commit is contained in:
parent
79536c105e
commit
3e0e138caa
1 changed files with 8 additions and 2 deletions
|
@ -50,7 +50,7 @@ class ShredDir(AsyncObject):
|
||||||
tasks.append(ShredDir(subpath, recursive))
|
tasks.append(ShredDir(subpath, recursive))
|
||||||
else:
|
else:
|
||||||
logger.warning(f"Subdirectory found: {subpath}, skipping (see -r/--recursive))")
|
logger.warning(f"Subdirectory found: {subpath}, skipping (see -r/--recursive))")
|
||||||
elif subpath.is_file():
|
elif await subpath.is_file():
|
||||||
tasks.append(ShredFile(subpath))
|
tasks.append(ShredFile(subpath))
|
||||||
return set(await asyncio.gather(*tasks))
|
return set(await asyncio.gather(*tasks))
|
||||||
|
|
||||||
|
@ -64,7 +64,13 @@ class ShredDir(AsyncObject):
|
||||||
tasks = []
|
tasks = []
|
||||||
for item in self.contents:
|
for item in self.contents:
|
||||||
tasks.append(item.shred(hash, dryrun))
|
tasks.append(item.shred(hash, dryrun))
|
||||||
return all(await asyncio.gather(*tasks))
|
try:
|
||||||
|
if all(await asyncio.gather(*tasks)):
|
||||||
|
await self.absolute_path.rmdir()
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Directory wipe failed: {e}")
|
||||||
|
return False
|
||||||
|
|
||||||
def __hash__(self) -> int:
|
def __hash__(self) -> int:
|
||||||
return hash(self.absolute_path)
|
return hash(self.absolute_path)
|
||||||
|
|
Loading…
Reference in a new issue