Skip to content

Commit

Permalink
qvm-template: Remove downloaded file if the download is interrupted.
Browse files Browse the repository at this point in the history
  • Loading branch information
WillyPillow committed Jul 29, 2020
1 parent 88ee572 commit 8aa9ab9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion qubesadmin/tools/qvm_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,12 +724,16 @@ def download(args, app, path_override=None,
done = True
break
except ConnectionError:
os.remove(target_suffix)
if attempt + 1 < args.retries:
print('\'%s\' download failed, retrying...' % spec,
file=sys.stderr)
except:
# Also remove file if interrupted by other means
os.remove(target_suffix)
raise
if not done:
print('\'%s\' download failed.' % spec, file=sys.stderr)
os.remove(target_suffix)
sys.exit(1)

def remove(args, app):
Expand Down

0 comments on commit 8aa9ab9

Please sign in to comment.