From e488b2c89c5af4d3aef4f005f07a26448c5e43bd Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Fri, 30 Apr 2021 02:08:50 -0600 Subject: [PATCH] Avoid crash when downloading tools --- scripts/wk/kit/tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/wk/kit/tools.py b/scripts/wk/kit/tools.py index 4f23b9a9..93311098 100644 --- a/scripts/wk/kit/tools.py +++ b/scripts/wk/kit/tools.py @@ -27,6 +27,8 @@ CACHED_DIRS = {} def download_file(out_path, source_url, as_new=False, overwrite=False): """Download a file using requests, returns pathlib.Path.""" out_path = pathlib.Path(out_path).resolve() + if as_new: + out_path = out_path.with_suffix(f'{out_path.suffix}.new') cursor_left = '\u001B[14D' print(f'Downloading...{cursor_left}', end='', flush=True) @@ -36,8 +38,6 @@ def download_file(out_path, source_url, as_new=False, overwrite=False): # Create destination directory out_path.parent.mkdir(parents=True, exist_ok=True) - if as_new: - out_path = out_path.with_suffix(f'{out_path.suffix}.new') # Request download response = requests.get(source_url, stream=True)