projects
/
oweals
/
minetest.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
809cb9f
)
Fix core.download_file() creating empty files on HTTP error
author
rubenwardy
<rw@rubenwardy.com>
Sun, 3 Feb 2019 17:30:33 +0000
(17:30 +0000)
committer
rubenwardy
<rw@rubenwardy.com>
Sun, 3 Feb 2019 17:31:28 +0000
(17:31 +0000)
src/gui/guiEngine.cpp
patch
|
blob
|
history
diff --git
a/src/gui/guiEngine.cpp
b/src/gui/guiEngine.cpp
index a61847a04a11c74e9e660e5742efa152898d9b69..92e9db0fc6519c6453c8cf596f782fd6956df0f6 100644
(file)
--- a/
src/gui/guiEngine.cpp
+++ b/
src/gui/guiEngine.cpp
@@
-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;
}
@@
-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;