From a3faa5d51f8e34239c0984e4a8f5d66e19188e1e Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 11 Oct 2023 18:13:27 +0200 Subject: [PATCH] fix(ls): catch error if there is no snapshot --- backupbot.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backupbot.py b/backupbot.py index 96c93c6..83e8991 100755 --- a/backupbot.py +++ b/backupbot.py @@ -201,7 +201,18 @@ def list_files(snapshot, path): cmd.append(snapshot) if path: cmd.append(path) - output = restic.internal.command_executor.execute(cmd) + try: + restic.cat.config() + output = restic.internal.command_executor.execute(cmd) + except ResticFailedError as error: + if 'no snapshot found' in str(error): + err_msg = f'There is no snapshot {snapshot}' + if SERVICE: + err_msg += f'for the app {SERVICE}' + logging.error(err_msg) + exit(1) + else: + raise error output = output.replace('}\n{', '}|{') results = list(map(json.loads, output.split('|'))) return results