Fix core.download_file() creating empty files on HTTP error

* backported commit 55a77e8094994cd5bb970b38b6a2bd394346ec36
This commit is contained in:
mckaygerhard 2023-01-05 16:34:19 -04:00
parent 512e670de9
commit fa1d056316

View File

@ -581,6 +581,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;