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 <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
7ec9614961
commit
b3244d05cd
@ -343,7 +343,7 @@ def check_file(file, suffix=''):
|
|||||||
if Path(file).is_file() or file == '': # exists
|
if Path(file).is_file() or file == '': # exists
|
||||||
return file
|
return file
|
||||||
elif file.startswith(('http:/', 'https:/')): # download
|
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
|
file = Path(urllib.parse.unquote(file).split('?')[0]).name # '%2F' to '/', split https://url.com/file.txt?auth
|
||||||
if Path(file).is_file():
|
if Path(file).is_file():
|
||||||
print(f'Found {url} locally at {file}') # file already exists
|
print(f'Found {url} locally at {file}') # file already exists
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user