Fix Files accidentally overwriting or deleting files
This commit is contained in:
parent
2e9a4e1c98
commit
8c12e26951
1 changed files with 2 additions and 0 deletions
|
|
@ -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()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue