Fix Files accidentally overwriting or deleting files

This commit is contained in:
Joscha 2025-11-03 02:17:36 +01:00
parent 2e9a4e1c98
commit 8c12e26951

View file

@ -128,6 +128,7 @@ class Files(Module):
if reason := self._file_db.verify_hash(path, cur_hash): if reason := self._file_db.verify_hash(path, cur_hash):
self.c.print(f"[red]Error:[/] {escape(reason)}") self.c.print(f"[red]Error:[/] {escape(reason)}")
return
# We want to avoid scenarios where we fail to remember a file we've # We want to avoid scenarios where we fail to remember a file we've
# written. It is better to remember a file with an incorrect hash than # written. It is better to remember a file with an incorrect hash than
@ -143,6 +144,7 @@ class Files(Module):
cur_hash = hash_file(path) cur_hash = hash_file(path)
if reason := self._file_db.verify_hash(path, cur_hash): if reason := self._file_db.verify_hash(path, cur_hash):
self.c.print(f"[red]Error:[/] {escape(reason)}") self.c.print(f"[red]Error:[/] {escape(reason)}")
return
try: try:
path.unlink() path.unlink()