From b3244d05cdb1934df47fee53b6f5b99b43fcf99b Mon Sep 17 00:00:00 2001 From: alex-fdias <73295477+alex-fdias@users.noreply.github.com> Date: Wed, 29 Jun 2022 17:18:08 +0100 Subject: [PATCH] Fix downloading file by URL (Windows) (#1958) as_posix() needed so that backslashes are output as forward slashes in the URL string (Windows) Co-authored-by: Glenn Jocher --- utils/general.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/general.py b/utils/general.py index 820e35d9..8331e7db 100755 --- a/utils/general.py +++ b/utils/general.py @@ -343,7 +343,7 @@ def check_file(file, suffix=''): if Path(file).is_file() or file == '': # exists return file elif file.startswith(('http:/', 'https:/')): # download - url = str(Path(file)).replace(':/', '://') # Pathlib turns :// -> :/ + url = str(Path(file).as_posix()).replace(':/', '://') # Pathlib turns :// -> :/ file = Path(urllib.parse.unquote(file).split('?')[0]).name # '%2F' to '/', split https://url.com/file.txt?auth if Path(file).is_file(): print(f'Found {url} locally at {file}') # file already exists