Skip to content

Commit

Permalink
remove on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed May 28, 2024
1 parent 7c6c696 commit 4391294
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions validphys2/src/validphys/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4391294

Please sign in to comment.