From 7fc7925d17df58e6dfb9eb1383f0895d5fadce58 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 30 Jul 2015 14:32:33 +0200 Subject: [PATCH] Propagator: Don't corrupt file with broken webserver #3373 --- src/libsync/propagatedownload.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index c97f19a88b6..e1e4ed48951 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -490,6 +490,15 @@ void PropagateDownloadFileQNAM::slotGetFinished() const QByteArray sizeHeader("Content-Length"); quint64 bodySize = job->reply()->rawHeader(sizeHeader).toULongLong(); + if (!job->reply()->rawHeader(sizeHeader).isEmpty() && _tmpFile.size() > 0 && bodySize == 0) { + // Strange bug with broken webserver or webfirewall https://github.com/owncloud/client/issues/3373#issuecomment-122672322 + // This happened when trying to resume a file. The Content-Range header was files, Content-Length was == 0 + qDebug() << bodySize << _item->_size << _tmpFile.size() << job->resumeStart(); + _tmpFile.remove(); + done(SyncFileItem::NormalError, QLatin1String("Broken webserver returning empty content length for non-empty file on resume")); + return; + } + if(bodySize > 0 && bodySize != _tmpFile.size() - job->resumeStart() ) { qDebug() << bodySize << _tmpFile.size() << job->resumeStart(); _propagator->_anotherSyncNeeded = true;