encrypt/decrypt_file: suppress FileNotFoundError...
when removing a potentially non-existent encryption/decryption target.
This commit is contained in:
parent
ef9edf7594
commit
932b5e9eda
10
buku
10
buku
@ -23,6 +23,7 @@ import argparse
|
||||
import calendar
|
||||
import cgi
|
||||
import collections
|
||||
import contextlib
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
@ -236,7 +237,8 @@ class BukuCrypt:
|
||||
print('File encrypted')
|
||||
sys.exit(0)
|
||||
except Exception as e:
|
||||
os.remove(encfile)
|
||||
with contextlib.suppress(FileNotFoundError):
|
||||
os.remove(encfile)
|
||||
LOGERR(e)
|
||||
sys.exit(1)
|
||||
|
||||
@ -331,11 +333,13 @@ class BukuCrypt:
|
||||
os.remove(encfile)
|
||||
print('File decrypted')
|
||||
except struct.error:
|
||||
os.remove(dbfile)
|
||||
with contextlib.suppress(FileNotFoundError):
|
||||
os.remove(dbfile)
|
||||
LOGERR('Tainted file')
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
os.remove(dbfile)
|
||||
with contextlib.suppress(FileNotFoundError):
|
||||
os.remove(dbfile)
|
||||
LOGERR(e)
|
||||
sys.exit(1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user