mirror of
https://github.com/mvt-project/mvt.git
synced 2024-06-24 05:18:55 +00:00
handle error cases better
This commit is contained in:
parent
44b677fdb2
commit
1288f8ca53
|
@ -53,7 +53,8 @@ def cli():
|
|||
help="File containing raw encryption key to use to decrypt the backup",
|
||||
mutually_exclusive=["password"])
|
||||
@click.argument("BACKUP_PATH", type=click.Path(exists=True))
|
||||
def decrypt_backup(destination, password, key_file, backup_path):
|
||||
@click.pass_context
|
||||
def decrypt_backup(ctx, destination, password, key_file, backup_path):
|
||||
backup = DecryptBackup(backup_path, destination)
|
||||
|
||||
if key_file:
|
||||
|
@ -75,6 +76,8 @@ def decrypt_backup(destination, password, key_file, backup_path):
|
|||
sekrit = Prompt.ask("Enter backup password", password=True)
|
||||
backup.decrypt_with_password(sekrit)
|
||||
|
||||
if not backup.can_process():
|
||||
ctx.exit(1)
|
||||
backup.process_backup()
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@ class DecryptBackup:
|
|||
self._backup = None
|
||||
self._decryption_key = None
|
||||
|
||||
def can_process(self) -> bool:
|
||||
return self._backup is not None
|
||||
|
||||
def process_backup(self):
|
||||
if not os.path.exists(self.dest_path):
|
||||
os.makedirs(self.dest_path)
|
||||
|
|
Loading…
Reference in New Issue
Block a user