[Pkg-owncloud-commits] [owncloud-client] 67/164: Propagator: Let network propagator job understand a new header OC-ErrorString

Sandro Knauß hefee-guest at moszumanska.debian.org
Sun Mar 22 11:56:54 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 d8b6e00fe78033b93f195893c2f75e574a892bef
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Thu Feb 26 15:52:07 2015 +0100

    Propagator: Let network propagator job understand a new header OC-ErrorString
    
    This allows the server to send a readable error string in many cases
---
 src/libsync/propagatedownload.cpp     | 11 +++++++++++
 src/libsync/propagatedownload.h       |  4 +---
 src/libsync/propagateremotedelete.cpp |  8 +++++++-
 src/libsync/propagateremotemkdir.cpp  |  6 +++++-
 src/libsync/propagateremotemove.cpp   |  8 +++++++-
 src/libsync/propagateupload.cpp       |  4 ++++
 6 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp
index 82923e0..712f2ca 100644
--- a/src/libsync/propagatedownload.cpp
+++ b/src/libsync/propagatedownload.cpp
@@ -263,6 +263,17 @@ void GETFileJob::slotTimeout()
     reply()->abort();
 }
 
+QString GETFileJob::errorString() const
+{
+    if (!_errorString.isEmpty()) {
+        return _errorString;
+    } else if (reply()->hasRawHeader("OC-ErrorString")) {
+        return reply()->rawHeader("OC-ErrorString");
+    } else {
+        return reply()->errorString();
+    }
+}
+
 void PropagateDownloadFileQNAM::start()
 {
     if (_propagator->_abortRequested.fetchAndAddRelaxed(0))
diff --git a/src/libsync/propagatedownload.h b/src/libsync/propagatedownload.h
index cc486ef..ad71f74 100644
--- a/src/libsync/propagatedownload.h
+++ b/src/libsync/propagatedownload.h
@@ -77,9 +77,7 @@ public:
     void giveBandwidthQuota(qint64 q);
     qint64 currentDownloadPosition();
 
-    QString errorString() {
-        return _errorString.isEmpty() ? reply()->errorString() : _errorString;
-    }
+    QString errorString() const;
 
     SyncFileItem::Status errorStatus() { return _errorStatus; }
 
diff --git a/src/libsync/propagateremotedelete.cpp b/src/libsync/propagateremotedelete.cpp
index ecae78c..8cbcf72 100644
--- a/src/libsync/propagateremotedelete.cpp
+++ b/src/libsync/propagateremotedelete.cpp
@@ -38,7 +38,13 @@ void DeleteJob::start()
 
 QString DeleteJob::errorString()
 {
-    return _timedout ? tr("Connection timed out") :  reply()->errorString();
+    if (_timedout) {
+        return tr("Connection timed out");
+    } else if (reply()->hasRawHeader("OC-ErrorString")) {
+        return reply()->rawHeader("OC-ErrorString");
+    } else {
+        return reply()->errorString();
+    }
 }
 
 bool DeleteJob::finished()
diff --git a/src/libsync/propagateremotemkdir.cpp b/src/libsync/propagateremotemkdir.cpp
index 431d4e6..1b724da 100644
--- a/src/libsync/propagateremotemkdir.cpp
+++ b/src/libsync/propagateremotemkdir.cpp
@@ -58,7 +58,11 @@ void PropagateRemoteMkdir::slotMkcolJobFinished()
         // This happens when the directory already exist. Nothing to do.
     } else if (err != QNetworkReply::NoError) {
         SyncFileItem::Status status = classifyError(err, _item._httpErrorCode);
-        done(status, _job->reply()->errorString());
+        auto errorString = _job->reply()->errorString();
+        if (_job->reply()->hasRawHeader("OC-ErrorString")) {
+            errorString = _job->reply()->rawHeader("OC-ErrorString");
+        }
+        done(status, errorString);
         return;
     } else if (_item._httpErrorCode != 201) {
         // Normaly we expect "201 Created"
diff --git a/src/libsync/propagateremotemove.cpp b/src/libsync/propagateremotemove.cpp
index e45affe..600bbb3 100644
--- a/src/libsync/propagateremotemove.cpp
+++ b/src/libsync/propagateremotemove.cpp
@@ -43,7 +43,13 @@ void MoveJob::start()
 
 QString MoveJob::errorString()
 {
-    return _timedout ? tr("Connection timed out") :  reply()->errorString();
+    if (_timedout) {
+        return tr("Connection timed out");
+    } else if (reply()->hasRawHeader("OC-ErrorString")) {
+        return reply()->rawHeader("OC-ErrorString");
+    } else {
+        return reply()->errorString();
+    }
 }
 
 bool MoveJob::finished()
diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp
index c3f50f3..848e538 100644
--- a/src/libsync/propagateupload.cpp
+++ b/src/libsync/propagateupload.cpp
@@ -475,6 +475,10 @@ void PropagateUploadFileQNAM::slotPutFinished()
             errorString += QLatin1String(" (") + rx.cap(1) + QLatin1Char(')');
         }
 
+        if (job->reply()->hasRawHeader("OC-ErrorString")) {
+            errorString = job->reply()->rawHeader("OC-ErrorString");
+        }
+
         if (_item._httpErrorCode == 412) {
             // Precondition Failed:   Maybe the bad etag is in the database, we need to clear the
             // parent folder etag so we won't read from DB next sync.

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