mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-28 07:54:49 +03:00
Download: Gracefully skip files with 404. #2227
This commit is contained in:
parent
5f44218727
commit
28d6d0dc1e
1 changed files with 17 additions and 10 deletions
|
@ -410,15 +410,21 @@ void PropagateDownloadFileQNAM::slotGetFinished()
|
||||||
|
|
||||||
// If we sent a 'Range' header and get 416 back, we want to retry
|
// If we sent a 'Range' header and get 416 back, we want to retry
|
||||||
// without the header.
|
// without the header.
|
||||||
bool badRangeHeader = job->resumeStart() > 0 && _item->_httpErrorCode == 416;
|
const bool badRangeHeader = job->resumeStart() > 0 && _item->_httpErrorCode == 416;
|
||||||
if (badRangeHeader) {
|
if (badRangeHeader) {
|
||||||
qDebug() << Q_FUNC_INFO << "server replied 416 to our range request, trying again without";
|
qDebug() << Q_FUNC_INFO << "server replied 416 to our range request, trying again without";
|
||||||
_propagator->_anotherSyncNeeded = true;
|
_propagator->_anotherSyncNeeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Getting a 404 probably means that the file was deleted on the server.
|
||||||
|
const bool fileNotFound = _item->_httpErrorCode == 404;
|
||||||
|
if (fileNotFound) {
|
||||||
|
qDebug() << Q_FUNC_INFO << "server replied 404, assuming file was deleted";
|
||||||
|
}
|
||||||
|
|
||||||
// Don't keep the temporary file if it is empty or we
|
// Don't keep the temporary file if it is empty or we
|
||||||
// used a bad range header.
|
// used a bad range header or the file's not on the server anymore.
|
||||||
if (_tmpFile.size() == 0 || badRangeHeader) {
|
if (_tmpFile.size() == 0 || badRangeHeader || fileNotFound) {
|
||||||
_tmpFile.close();
|
_tmpFile.close();
|
||||||
_tmpFile.remove();
|
_tmpFile.remove();
|
||||||
_propagator->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo());
|
_propagator->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo());
|
||||||
|
@ -439,19 +445,20 @@ void PropagateDownloadFileQNAM::slotGetFinished()
|
||||||
if (err == QNetworkReply::OperationCanceledError && reply->property(owncloudCustomSoftErrorStringC).isValid()) {
|
if (err == QNetworkReply::OperationCanceledError && reply->property(owncloudCustomSoftErrorStringC).isValid()) {
|
||||||
job->setErrorString(reply->property(owncloudCustomSoftErrorStringC).toString());
|
job->setErrorString(reply->property(owncloudCustomSoftErrorStringC).toString());
|
||||||
job->setErrorStatus(SyncFileItem::SoftError);
|
job->setErrorStatus(SyncFileItem::SoftError);
|
||||||
|
} else if (badRangeHeader) {
|
||||||
|
// Can't do this in classifyError() because 416 without a
|
||||||
|
// Range header should result in NormalError.
|
||||||
|
job->setErrorStatus(SyncFileItem::SoftError);
|
||||||
|
} else if (fileNotFound) {
|
||||||
|
job->setErrorString(tr("File was deleted from server"));
|
||||||
|
job->setErrorStatus(SyncFileItem::SoftError);
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncFileItem::Status status = job->errorStatus();
|
SyncFileItem::Status status = job->errorStatus();
|
||||||
|
|
||||||
|
|
||||||
if (status == SyncFileItem::NoStatus) {
|
if (status == SyncFileItem::NoStatus) {
|
||||||
status = classifyError(err, _item->_httpErrorCode);
|
status = classifyError(err, _item->_httpErrorCode);
|
||||||
}
|
}
|
||||||
if (badRangeHeader) {
|
|
||||||
// Can't do this in classifyError() because 416 without a
|
|
||||||
// Range header should result in NormalError.
|
|
||||||
status = SyncFileItem::SoftError;
|
|
||||||
}
|
|
||||||
done(status, job->errorString());
|
done(status, job->errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue