mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
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
This commit is contained in:
parent
3e3ca14b4c
commit
65a307970b
1 changed files with 15 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue