Преглед изворни кода

Propagator: Don't corrupt file with broken webserver #3373

Markus Goetz пре 10 година
родитељ
комит
7fc7925d17
1 измењених фајлова са 9 додато и 0 уклоњено
  1. 9 0
      src/libsync/propagatedownload.cpp

+ 9 - 0
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;