Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaas Freitag <freitag@owncloud.com>2014-11-20 20:49:34 +0300
committerKlaas Freitag <freitag@owncloud.com>2014-11-20 20:49:34 +0300
commit65a307970bd9987b90d9b2087affc9c6c3deaf93 (patch)
tree32264924bcd61718c8f42da21b85251f5e344093 /src/mirall
parent3e3ca14b4c58fd4567834065e8f05dce3e611939 (diff)
Propagator: Compare the actual file size with the request content length
The values must match. Otherwise the request did succeed, but the file was not downloaded completely. This fixes https://github.com/owncloud/mirall/issues/2528
Diffstat (limited to 'src/mirall')
-rw-r--r--src/mirall/propagator_qnam.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index 199a65047..639104ecf 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -742,6 +742,21 @@ void PropagateDownloadFileQNAM::slotGetFinished()
_tmpFile.close();
_tmpFile.flush();
+
+ /* Check that the size of the GET reply matches the file size. There have been cases
+ * reported that if a server breaks behind a proxy, the GET is still a 200 but is
+ * truncated, as described here: https://github.com/owncloud/mirall/issues/2528
+ */
+ const QByteArray sizeHeader("Content-Length");
+ qint64 bodySize = job->reply()->rawHeader(sizeHeader).toLongLong();
+
+ if( bodySize != _tmpFile.size() ) {
+ _propagator->_journal->setDownloadInfo(_item._file, SyncJournalDb::DownloadInfo());
+ _tmpFile.remove();
+ done(SyncFileItem::SoftError, tr("The file could not be downloaded completely."));
+ return;
+ }
+
downloadFinished();
}