[Pkg-owncloud-commits] [owncloud-client] 169/498: Download: Gracefully skip files with 404. #2227

Sandro Knauß hefee-guest at moszumanska.debian.org
Tue Aug 11 14:48:47 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 28d6d0dc1eb3b378e17df78021de8b5969352947
Author: Christian Kamm <kamm at incasoftware.de>
Date:   Fri Jun 5 11:12:21 2015 +0200

    Download: Gracefully skip files with 404. #2227
---
 src/libsync/propagatedownload.cpp | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp
index c7a5d64..a1dff6e 100644
--- a/src/libsync/propagatedownload.cpp
+++ b/src/libsync/propagatedownload.cpp
@@ -410,15 +410,21 @@ void PropagateDownloadFileQNAM::slotGetFinished()
 
         // If we sent a 'Range' header and get 416 back, we want to retry
         // without the header.
-        bool badRangeHeader = job->resumeStart() > 0 && _item->_httpErrorCode == 416;
+        const bool badRangeHeader = job->resumeStart() > 0 && _item->_httpErrorCode == 416;
         if (badRangeHeader) {
             qDebug() << Q_FUNC_INFO << "server replied 416 to our range request, trying again without";
             _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
-        // used a bad range header.
-        if (_tmpFile.size() == 0 || badRangeHeader) {
+        // used a bad range header or the file's not on the server anymore.
+        if (_tmpFile.size() == 0 || badRangeHeader || fileNotFound) {
             _tmpFile.close();
             _tmpFile.remove();
             _propagator->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo());
@@ -439,19 +445,20 @@ void PropagateDownloadFileQNAM::slotGetFinished()
         if (err == QNetworkReply::OperationCanceledError && reply->property(owncloudCustomSoftErrorStringC).isValid()) {
             job->setErrorString(reply->property(owncloudCustomSoftErrorStringC).toString());
             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();
-
-
         if (status == SyncFileItem::NoStatus) {
             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());
         return;
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list