Skip to content

Commit

Permalink
Fix URL parsing bug (#4998)
Browse files Browse the repository at this point in the history
* added callbacks

* added back callback to main

* added save_dir to callback output

* merged in upstream

* removed ghost code

* fixed parsing error for google temp links

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
kalenmike and glenn-jocher committed Sep 29, 2021
1 parent cd35a00 commit 76d301b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def check_file(file, suffix=''):
return file
elif file.startswith(('http:/', 'https:/')): # download
url = str(Path(file)).replace(':/', '://') # Pathlib turns :// -> :/
file = Path(urllib.parse.unquote(file)).name.split('?')[0] # '%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
print(f'Downloading {url} to {file}...')
torch.hub.download_url_to_file(url, file)
assert Path(file).exists() and Path(file).stat().st_size > 0, f'File download failed: {url}' # check
Expand Down

0 comments on commit 76d301b

Please sign in to comment.