BasicSR
BasicSR copied to clipboard
interrupted download results in stuck corrupted file
https://github.com/XPixelGroup/BasicSR/blob/ce5c55aec0d14a399998a8c63fc650fdce3eb519/basicsr/utils/download_util.py#L94-L97
If the process stops while downloading a file, then the file will exist but be incomplete and the corrupted file will be returned the next time the function is called.
Solution:
tmp_file = cached_file + '.tmp'
download_url_to_file(url, tmp_file, hash_prefix=None, progress=progress)
os.replace(tmp_file, cached_file)
Download to a temporary path then move/rename to the output file.
https://pytorch.org/docs/stable/hub.html#torch.hub.download_url_to_file
The documentation also suggests using temporary files for this reason.
I'd make the PR myself but my clone is failing because of my messed up OS. Sorry for any inconvenience and thank you for reading/looking into this issue.