Skip to content

Commit

Permalink
Address review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
grorp committed Mar 6, 2024
1 parent c15eb45 commit 727a973
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/gui/guiEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,14 +663,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"));
if (!httpfetch_sync_interruptible(fetch_request, fetch_result))
return false;
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;
Expand Down

0 comments on commit 727a973

Please sign in to comment.