fix(decrypt): wrap the yield and cleanup code in try-finally
Without this, the cleanup code won't run after if `sys.exit()` is called when we yield Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
parent
53d4153bcd
commit
39be50c773
1 changed files with 9 additions and 7 deletions
|
|
@ -661,13 +661,15 @@ def decrypt_backup(file_path: str, passphrase: str):
|
|||
decrypted_file=file_path,
|
||||
)
|
||||
frappe.utils.execute_in_shell(command)
|
||||
yield
|
||||
if os.path.exists(file_path + ".gpg"):
|
||||
if os.path.exists(file_path):
|
||||
os.remove(file_path)
|
||||
if os.path.exists(file_path.rstrip(".gz")):
|
||||
os.remove(file_path.rstrip(".gz"))
|
||||
os.rename(file_path + ".gpg", file_path)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if os.path.exists(file_path_with_ext):
|
||||
if os.path.exists(file_path):
|
||||
os.remove(file_path)
|
||||
if os.path.exists(file_path.rstrip(".gz")):
|
||||
os.remove(file_path.rstrip(".gz"))
|
||||
os.rename(file_path_with_ext, file_path)
|
||||
|
||||
|
||||
def backup(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue