[Pkg-owncloud-commits] [owncloud-client] 39/219: Propagator: Also parse OC-ETag header

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 11 14:43:07 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 12e2bac16b72dfca99e94681222d886de85978ad
Author: Markus Goetz <markus at woboq.com>
Date:   Fri Aug 29 16:23:44 2014 +0200

    Propagator: Also parse OC-ETag header
    
    Client side part of https://github.com/owncloud/core/issues/9005
---
 src/mirall/propagator_legacy.cpp | 21 ++++++++++++++++-----
 src/mirall/propagator_qnam.cpp   | 18 +++++++++++++++---
 2 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/src/mirall/propagator_legacy.cpp b/src/mirall/propagator_legacy.cpp
index 64ebab5..e1750f9 100644
--- a/src/mirall/propagator_legacy.cpp
+++ b/src/mirall/propagator_legacy.cpp
@@ -44,6 +44,18 @@
 
 namespace Mirall {
 
+static QByteArray get_etag_from_reply(ne_request *req)
+{
+    QByteArray ret = parseEtag(ne_get_response_header(req, "OC-ETag"));
+    if (ret.isEmpty()) {
+        ret = parseEtag(ne_get_response_header(req, "ETag"));
+    }
+    if (ret.isEmpty()) {
+        ret = parseEtag(ne_get_response_header(req, "etag"));
+    }
+    return ret;
+}
+
 
 void PropagateUploadFileLegacy::start()
 {
@@ -287,7 +299,8 @@ bool PropagateNeonJob::updateMTimeAndETag(const char* uri, time_t mtime)
     if (updateErrorFromSession(neon_stat, req.data())) {
         return false;
     } else {
-        _item._etag = parseEtag(ne_get_response_header(req.data(), "etag"));
+        _item._etag = get_etag_from_reply(req.data());
+
         QByteArray fid = parseFileId(req.data());
         if( _item._fileId.isEmpty() ) {
             _item._fileId = fid;
@@ -390,9 +403,7 @@ void PropagateDownloadFileLegacy::install_content_reader( ne_request *req, void
         return;
     }
 
-    QByteArray etag = parseEtag(ne_get_response_header(req, "etag"));
-    if(etag.isEmpty())
-        etag = parseEtag(ne_get_response_header(req, "ETag"));
+    QByteArray etag = get_etag_from_reply(req);
 
     if (etag.isEmpty()) {
         qDebug() << Q_FUNC_INFO << "No E-Tag reply by server, considering it invalid" << ne_get_response_header(req, "etag");
@@ -593,7 +604,7 @@ void PropagateDownloadFileLegacy::start()
             }
             return;
         }
-        _item._etag = parseEtag(ne_get_response_header(req.data(), "etag"));
+        _item._etag = get_etag_from_reply(req.data());
         break;
     } while (1);
 
diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index 0bbd75b..d066d25 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -38,6 +38,15 @@ static qint64 chunkSize() {
     return chunkSize;
 }
 
+static QByteArray get_etag_from_reply(QNetworkReply *reply)
+{
+    QByteArray ret = parseEtag(reply->rawHeader("OC-ETag"));
+    if (ret.isEmpty()) {
+        ret = parseEtag(reply->rawHeader("ETag"));
+    }
+    return ret;
+}
+
 /**
  * Fiven an error from the network, map to a SyncFileItem::Status error
  */
@@ -294,7 +303,8 @@ void PropagateUploadFileQNAM::slotPutFinished()
         return;
     }
 
-    bool finished = job->reply()->hasRawHeader("ETag");
+    bool finished = job->reply()->hasRawHeader("ETag")
+            || job->reply()->hasRawHeader("OC-ETag");
 
     if (!finished) {
         QFileInfo fi(_propagator->_localDir + _item._file);
@@ -343,7 +353,9 @@ void PropagateUploadFileQNAM::slotPutFinished()
         _item._fileId = fid;
     }
 
-    _item._etag = parseEtag(job->reply()->rawHeader("ETag"));
+    QByteArray etag = get_etag_from_reply(job->reply());
+    _item._etag = etag;
+
     _item._responseTimeStamp = job->responseTimestamp();
 
     if (job->reply()->rawHeader("X-OC-MTime") != "accepted") {
@@ -449,8 +461,8 @@ void GETFileJob::slotMetaDataChanged()
         // We will handle the error when the job is finished.
         return;
     }
+    _etag = get_etag_from_reply(reply());
 
-    _etag = parseEtag(reply()->rawHeader("Etag"));
     if (!_directDownloadUrl.isEmpty() && !_etag.isEmpty()) {
         qDebug() << Q_FUNC_INFO << "Direct download used, ignoring server ETag" << _etag;
         _etag = QByteArray(); // reset received ETag

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