summaryrefslogtreecommitdiffstats
path: root/api/logic/net/FileSink.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-05-09 03:08:38 +0200
committerPetr Mrázek <peterix@gmail.com>2017-05-09 03:08:38 +0200
commit8a526fab0e0d8c7baec0abc022ef62fb72a262ae (patch)
treed0d952ea51be3302f5a42b281fdc1f5ecfdc7698 /api/logic/net/FileSink.cpp
parent8fe18cfabc8c42d10e6b4345f80dfd3ea67233d6 (diff)
downloadMultiMC-8a526fab0e0d8c7baec0abc022ef62fb72a262ae.tar
MultiMC-8a526fab0e0d8c7baec0abc022ef62fb72a262ae.tar.gz
MultiMC-8a526fab0e0d8c7baec0abc022ef62fb72a262ae.tar.lz
MultiMC-8a526fab0e0d8c7baec0abc022ef62fb72a262ae.tar.xz
MultiMC-8a526fab0e0d8c7baec0abc022ef62fb72a262ae.zip
GH-1885 make FileSink save (even empty) files when the HTTP response is 200 or 203
Diffstat (limited to 'api/logic/net/FileSink.cpp')
-rw-r--r--api/logic/net/FileSink.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/api/logic/net/FileSink.cpp b/api/logic/net/FileSink.cpp
index 7dfc4336..f52c5788 100644
--- a/api/logic/net/FileSink.cpp
+++ b/api/logic/net/FileSink.cpp
@@ -71,8 +71,18 @@ JobStatus FileSink::abort()
JobStatus FileSink::finalize(QNetworkReply& reply)
{
+ bool gotFile = false;
+ QVariant statusCodeV = reply.attribute(QNetworkRequest::HttpStatusCodeAttribute);
+ bool validStatus = false;
+ int statusCode = statusCodeV.toInt(&validStatus);
+ if(validStatus)
+ {
+ // this leaves out 304 Not Modified
+ gotFile = statusCode == 200 || statusCode == 203;
+ }
// if we wrote any data to the save file, we try to commit the data to the real file.
- if (wroteAnyData)
+ // if it actually got a proper file, we write it even if it was empty
+ if (gotFile || wroteAnyData)
{
// ask validators for data consistency
// we only do this for actual downloads, not 'your data is still the same' cache hits