From 8a526fab0e0d8c7baec0abc022ef62fb72a262ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 9 May 2017 03:08:38 +0200 Subject: GH-1885 make FileSink save (even empty) files when the HTTP response is 200 or 203 --- api/logic/net/FileSink.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'api/logic/net') 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 -- cgit v1.2.3