From 4391294e3736d9f821a1e56c7f84b009f3a7322e Mon Sep 17 00:00:00 2001 From: juacrumar Date: Tue, 28 May 2024 11:26:18 +0200 Subject: [PATCH] remove on failure --- validphys2/src/validphys/loader.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/validphys2/src/validphys/loader.py b/validphys2/src/validphys/loader.py index a75d05143d..4e8e54b429 100644 --- a/validphys2/src/validphys/loader.py +++ b/validphys2/src/validphys/loader.py @@ -921,7 +921,7 @@ def _download_and_show(response, stream): sys.stdout.write('\n') -def download_file(url, stream_or_path, make_parents=False): +def download_file(url, stream_or_path, make_parents=False, delete_on_failure=False): """Download a file and show a progress bar if the INFO log level is enabled. If ``make_parents`` is ``True`` ``stream_or_path`` is path-like, all the parent folders will @@ -950,7 +950,7 @@ def download_file(url, stream_or_path, make_parents=False): p.parent.mkdir(exist_ok=True, parents=True) download_target = tempfile.NamedTemporaryFile( - delete=False, dir=p.parent, prefix=p.name, suffix='.part' + delete=delete_on_failure, dir=p.parent, prefix=p.name, suffix='.part' ) with download_target as f: @@ -1344,7 +1344,7 @@ def download_eko(self, thid): # Check that we have the theory we need theory = self.check_theoryID(thid) target_path = theory.path / "eko.tar" - download_file(remote[thid], target_path) + download_file(remote[thid], target_path, delete_on_failure=True) def download_vp_output_file(self, filename, **kwargs): try: