fix(ls): catch error if there is no snapshot
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Moritz 2023-10-11 18:13:27 +02:00
parent a3f27fa6ba
commit a3faa5d51f
1 changed files with 12 additions and 1 deletions

View File

@ -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