]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
PropagateDownload: Throw an error if the file is empty while it should not have been...
authorOlivier Goffart <olivier@woboq.com>
Fri, 29 Apr 2016 06:49:27 +0000 (08:49 +0200)
committerMarkus Goetz <markus@woboq.com>
Fri, 29 Apr 2016 06:49:27 +0000 (08:49 +0200)
If the downloaded file is empty but the PROPFIND previously announced it
should not have been empty, this might mean the file was somehow corrupted
because of a bug on the server and that we should therefore not accept
the file.

Normaly we accept a change between the actual size of the file and what we
got during discovery because the file might have been updated to a new version
inbetween. But after this patch we won't accept the file if it was replaced
by an empty file.

Will help for issue #4583
Also requested by IL for issue 548

src/libsync/propagatedownload.cpp

index 2b6e0140e2f02390bb0cf50ced83ca17a28f4a4e..0dd920573ada005edc8b0ccfd4881ace9b6298f3 100644 (file)
@@ -543,6 +543,14 @@ void PropagateDownloadFileQNAM::slotGetFinished()
         return;
     }
 
+    if (_tmpFile.size() == 0 && _item->_size > 0) {
+        FileSystem::remove(_tmpFile.fileName());
+        done(SyncFileItem::NormalError,
+             tr("The downloaded file is empty despite the server announced it should have been %1.")
+                .arg(Utility::octetsToString(_item->_size)));
+        return;
+    }
+
     // Do checksum validation for the download. If there is no checksum header, the validator
     // will also emit the validated() signal to continue the flow in slot downloadFinished()
     // as this is (still) also correct.