You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the download_single_file function encounters a URL that points to a non-existent file, it currently does not raise an error and proceeds as if downloading a regular file. As a result, the downloaded file is merely a webpage saying “文件不存在”.
A notable challenge is that the server still responds with a status code of 200 instead of 404 in such case. An ugly-but-effective way solution involves checking for redirection in resp: an exist file will undergo a redirection from files/?dl=1 to seafhttp/files/. In contrast, a Not Found response is served directly from files/?dl=1 without any redirection.
THU-Cloud-Downloader/thu_cloud_download.py
Lines 89 to 95 in 8b610c4
When the download_single_file function encounters a URL that points to a non-existent file, it currently does not raise an error and proceeds as if downloading a regular file. As a result, the downloaded file is merely a webpage saying “文件不存在”.
A notable challenge is that the server still responds with a status code of 200 instead of 404 in such case. An ugly-but-effective way solution involves checking for redirection in
resp
: an exist file will undergo a redirection fromfiles/?dl=1
toseafhttp/files/
. In contrast, a Not Found response is served directly fromfiles/?dl=1
without any redirection.Wonder if there are more elegant solutions...
The text was updated successfully, but these errors were encountered: