Fix indents causing file to close during shred

This commit is contained in:
Darryl Nixon 2023-07-16 11:29:46 -07:00
parent e69775471f
commit 2b20dc6cc8

View file

@ -103,27 +103,27 @@ class ShredFile(AsyncObject):
self.sha1 = sha1.digest()
logger.info(f"Got hash {sha1.hexdigest()}")
# First pass: Overwrite with binary zeroes
logger.info(f"[1/4] Writing zeroes ({self.absolute_path.name})")
await file.seek(0)
if not dryrun:
await file.write(b"\x00" * self.byte_size)
await file.flush()
# First pass: Overwrite with binary zeroes
logger.info(f"[1/4] Writing zeroes ({self.absolute_path.name})")
await file.seek(0)
if not dryrun:
await file.write(b"\x00" * self.byte_size)
await file.flush()
# Second pass: Overwrite with binary ones
logger.info(f"[2/4] Writing ones ({self.absolute_path.name})")
await file.seek(0)
if not dryrun:
await file.write(b"\xff" * self.byte_size)
await file.flush()
# Second pass: Overwrite with binary ones
logger.info(f"[2/4] Writing ones ({self.absolute_path.name})")
await file.seek(0)
if not dryrun:
await file.write(b"\xff" * self.byte_size)
await file.flush()
# Third pass: Overwrite with random data
logger.info(f"[3/4] Writing randoms ({self.absolute_path.name})")
await file.seek(0)
random_data = token_bytes(self.byte_size)
if not dryrun:
await file.write(random_data)
await file.flush()
# Third pass: Overwrite with random data
logger.info(f"[3/4] Writing randoms ({self.absolute_path.name})")
await file.seek(0)
random_data = token_bytes(self.byte_size)
if not dryrun:
await file.write(random_data)
await file.flush()
# Remove the file
logger.info(f"[4/4] Unlinking {self.absolute_path}")