Skip to content

Commit 9a071d6

Browse files
committedFeb 3, 2019
Fix core.download_file() creating empty files on HTTP error
1 parent 809cb9f commit 9a071d6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎src/gui/guiEngine.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ bool GUIEngine::downloadFile(const std::string &url, const std::string &target)
530530
{
531531
#if USE_CURL
532532
std::ofstream target_file(target.c_str(), std::ios::out | std::ios::binary);
533-
534533
if (!target_file.good()) {
535534
return false;
536535
}
@@ -543,6 +542,8 @@ bool GUIEngine::downloadFile(const std::string &url, const std::string &target)
543542
httpfetch_sync(fetch_request, fetch_result);
544543

545544
if (!fetch_result.succeeded) {
545+
target_file.close();
546+
fs::DeleteSingleFileOrEmptyDirectory(target);
546547
return false;
547548
}
548549
target_file << fetch_result.data;

0 commit comments

Comments
 (0)