[Pkg-owncloud-commits] [owncloud-client] 48/103: In case of error, report the right error instead of missing etag

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Apr 30 18:08:58 UTC 2014


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 3fac5f91c81fd5ec1a1e95d34d1850bc88aa57ac
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Tue Apr 22 12:34:03 2014 +0200

    In case of error, report the right error instead of missing etag
    
    also, missing etag is not a fatal error
---
 src/mirall/propagator_qnam.cpp | 16 +++++++++++++++-
 src/mirall/propagator_qnam.h   |  6 +++++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index b0e5ccd..800fad2 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -358,17 +358,25 @@ void GETFileJob::start() {
 
 void GETFileJob::slotMetaDataChanged()
 {
+    qDebug() << Q_FUNC_INFO << reply()->error() << reply()->errorString() << reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute);
+    if (reply()->error() != QNetworkReply::NoError ) {
+        // We will handle the error when the job is finished.
+        return;
+    }
+
     QByteArray etag = parseEtag(reply()->rawHeader("Etag"));
 
     if (etag.isEmpty()) {
         qDebug() << Q_FUNC_INFO << "No E-Tag reply by server, considering it invalid";
         _errorString = tr("No E-Tag received from server, check Proxy/Gateway");
+        _errorStatus = SyncFileItem::NormalError;
         reply()->abort();
         return;
     } else if (!_expectedEtagForResume.isEmpty() && _expectedEtagForResume != etag) {
         qDebug() << Q_FUNC_INFO <<  "We received a different E-Tag for resuming!"
                 << _expectedEtagForResume << "vs" << etag;
         _errorString = tr("We received a different E-Tag for resuming. Retrying next time.");
+        _errorStatus = SyncFileItem::NormalError;
         reply()->abort();
         return;
     }
@@ -383,6 +391,7 @@ void GETFileJob::slotReadyRead()
         qint64 r = reply()->read(buffer.data(), bufferSize);
         if (r < 0) {
             _errorString = reply()->errorString();
+            _errorStatus = SyncFileItem::NormalError;
             qDebug() << "Error while reading from device: " << _errorString;
             reply()->abort();
             return;
@@ -391,6 +400,7 @@ void GETFileJob::slotReadyRead()
         qint64 w = _device->write(buffer.constData(), r);
         if (w != r) {
             _errorString = _device->errorString();
+            _errorStatus = SyncFileItem::NormalError;
             qDebug() << "Error while writing to file" << w << r <<  _errorString;
             reply()->abort();
             return;
@@ -497,7 +507,11 @@ void PropagateDownloadFileQNAM::slotGetFinished()
         }
         _item._httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
         _propagator->_activeJobs--;
-        done(classifyError(err, _item._httpErrorCode), job->errorString());
+        SyncFileItem::Status status = job->errorStatus();
+        if (status == SyncFileItem::NoStatus) {
+            status = classifyError(err, _item._httpErrorCode);
+        }
+        done(status, job->errorString());
         return;
     }
 
diff --git a/src/mirall/propagator_qnam.h b/src/mirall/propagator_qnam.h
index 93a39fa..15d5bea 100644
--- a/src/mirall/propagator_qnam.h
+++ b/src/mirall/propagator_qnam.h
@@ -101,6 +101,7 @@ class GETFileJob : public AbstractNetworkJob {
     QMap<QByteArray, QByteArray> _headers;
     QString _errorString;
     QByteArray _expectedEtagForResume;
+    SyncFileItem::Status _errorStatus;
 public:
 
     // DOES NOT take owncership of the device.
@@ -108,7 +109,8 @@ public:
                         const QMap<QByteArray, QByteArray> &headers, QByteArray expectedEtagForResume,
                         QObject* parent = 0)
     : AbstractNetworkJob(account, path, parent),
-      _device(device), _headers(headers), _expectedEtagForResume(expectedEtagForResume) {}
+      _device(device), _headers(headers), _expectedEtagForResume(expectedEtagForResume),
+      _errorStatus(SyncFileItem::NoStatus) {}
 
     virtual void start();
     virtual bool finished() {
@@ -120,6 +122,8 @@ public:
         return _errorString.isEmpty() ? reply()->errorString() : _errorString;
     };
 
+    SyncFileItem::Status errorStatus() { return _errorStatus; }
+
 signals:
     void finishedSignal();
     void downloadProgress(qint64,qint64);

-- 
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