From fa1d056316fd01d04ab62b6687925dc66b23c2f9 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Thu, 5 Jan 2023 16:34:19 -0400 Subject: [PATCH] Fix core.download_file() creating empty files on HTTP error * backported commit 55a77e8094994cd5bb970b38b6a2bd394346ec36 --- src/guiEngine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/guiEngine.cpp b/src/guiEngine.cpp index 8661b1ca2..95cd7c0e0 100644 --- a/src/guiEngine.cpp +++ b/src/guiEngine.cpp @@ -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;