We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e792831 commit f17abdfCopy full SHA for f17abdf
Core/Downloader/HttpClient.cpp
@@ -81,6 +81,9 @@ bool HttpClient::downloadAs(string url, string filepath)
81
// forward all data to this func
82
curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, &HttpClient::writeToFile);
83
84
+ // try to write a temp file instead of the real file
85
+ string tmpFile = filepath + ".tmp";
86
+
87
// open the file
88
FILE * file = fopen(filepath.c_str(), "wb");
89
if (file)
@@ -93,6 +96,9 @@ bool HttpClient::downloadAs(string url, string filepath)
93
96
94
97
fclose(file);
95
98
99
+ // rename it to real filename // TODO: handle exceptions (interrupt or bad request)
100
+ rename(tmpFile.c_str(), filepath.c_str());
101
102
return res == CURLE_OK;
103
}
104
0 commit comments