From 8aa9ab9e89e7cc063be77000cbba7e23ba4e9891 Mon Sep 17 00:00:00 2001 From: WillyPillow Date: Wed, 29 Jul 2020 19:31:25 +0800 Subject: [PATCH] qvm-template: Remove downloaded file if the download is interrupted. --- qubesadmin/tools/qvm_template.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qubesadmin/tools/qvm_template.py b/qubesadmin/tools/qvm_template.py index ca3818b..1c8ca61 100644 --- a/qubesadmin/tools/qvm_template.py +++ b/qubesadmin/tools/qvm_template.py @@ -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):