mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-27 17:28:41 +00:00
Allow sync HTTP fetches to be interrupted to fix hanging (#14412)
Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
This commit is contained in:
parent
32f68f35cf
commit
f07e1026ac
6 changed files with 56 additions and 11 deletions
|
@ -629,13 +629,15 @@ bool GUIEngine::downloadFile(const std::string &url, const std::string &target)
|
|||
fetch_request.caller = HTTPFETCH_SYNC;
|
||||
fetch_request.timeout = std::max(MIN_HTTPFETCH_TIMEOUT,
|
||||
(long)g_settings->getS32("curl_file_download_timeout"));
|
||||
httpfetch_sync(fetch_request, fetch_result);
|
||||
bool completed = httpfetch_sync_interruptible(fetch_request, fetch_result);
|
||||
|
||||
if (!fetch_result.succeeded) {
|
||||
if (!completed || !fetch_result.succeeded) {
|
||||
target_file.close();
|
||||
fs::DeleteSingleFileOrEmptyDirectory(target);
|
||||
return false;
|
||||
}
|
||||
// TODO: directly stream the response data into the file instead of first
|
||||
// storing the complete response in memory
|
||||
target_file << fetch_result.data;
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue