Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix core.download_file() creating empty files on HTTP error
  • Loading branch information
rubenwardy committed Feb 3, 2019
1 parent 809cb9f commit 9a071d6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/gui/guiEngine.cpp
Expand Up @@ -530,7 +530,6 @@ bool GUIEngine::downloadFile(const std::string &url, const std::string &target)
{
#if USE_CURL
std::ofstream target_file(target.c_str(), std::ios::out | std::ios::binary);

if (!target_file.good()) {
return false;
}
Expand All @@ -543,6 +542,8 @@ bool GUIEngine::downloadFile(const std::string &url, const std::string &target)
httpfetch_sync(fetch_request, fetch_result);

if (!fetch_result.succeeded) {
target_file.close();
fs::DeleteSingleFileOrEmptyDirectory(target);
return false;
}
target_file << fetch_result.data;
Expand Down

0 comments on commit 9a071d6

Please sign in to comment.