[Pkg-owncloud-commits] [owncloud-client] 13/47: Report an error if fetching the etag fails

Sandro Knauß hefee-guest at moszumanska.debian.org
Mon Feb 17 18:06:33 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 8f1494f8f2594eeff6dff622e31f15caddf83c6a
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Thu Feb 6 17:02:10 2014 +0100

    Report an error if fetching the etag fails
    
    Very important in case of renames, else, if the server did not perform
    the rename, we may end up deleting the files
---
 src/mirall/owncloudpropagator.cpp | 20 ++++++++++----------
 src/mirall/owncloudpropagator.h   |  6 +++++-
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/mirall/owncloudpropagator.cpp b/src/mirall/owncloudpropagator.cpp
index 9aca9cd..6e9109b 100644
--- a/src/mirall/owncloudpropagator.cpp
+++ b/src/mirall/owncloudpropagator.cpp
@@ -381,7 +381,8 @@ void PropagateUploadFile::start()
         if( trans->modtime_accepted ) {
             _item._etag = parseEtag(hbf_transfer_etag( trans.data() ));
         } else {
-            updateMTimeAndETag(uri.data(), _item._modtime);
+            if (!updateMTimeAndETag(uri.data(), _item._modtime))
+                return;
         }
 
         _propagator->_journal->setFileRecord(SyncJournalFileRecord(_item, _propagator->_localDir + _item._file));
@@ -473,7 +474,7 @@ static QString parseFileId(ne_request *req) {
     return fileId;
 }
 
-void PropagateItemJob::updateMTimeAndETag(const char* uri, time_t mtime)
+bool PropagateItemJob::updateMTimeAndETag(const char* uri, time_t mtime)
 {
     QByteArray modtime = QByteArray::number(qlonglong(mtime));
     ne_propname pname;
@@ -497,12 +498,8 @@ void PropagateItemJob::updateMTimeAndETag(const char* uri, time_t mtime)
     // get the etag
     QScopedPointer<ne_request, ScopedPointerHelpers> req(ne_request_create(_propagator->_session, "HEAD", uri));
     int neon_stat = ne_request_dispatch(req.data());
-    const ne_status *status = ne_get_status(req.data());
-    if( neon_stat != NE_OK || status->klass != 2 ) {
-        // error happend
-        _item._httpErrorCode = status->code;
-        qDebug() << "Could not issue HEAD request for ETag." << ne_get_error(_propagator->_session);
-        _item._errorString = ne_get_error( _propagator->_session );
+    if (updateErrorFromSession(neon_stat, req.data())) {
+        return false;
     } else {
         _item._etag = parseEtag(ne_get_response_header(req.data(), "etag"));
         QString fid = parseFileId(req.data());
@@ -516,6 +513,7 @@ void PropagateItemJob::updateMTimeAndETag(const char* uri, time_t mtime)
                 qDebug() << "FileID is " << _item._fileId;
             }
         }
+        return true;
     }
 }
 
@@ -885,7 +883,8 @@ void PropagateRemoteRename::start()
             // Note: we also update the mtime because the server do not keep the mtime when moving files
             QScopedPointer<char, QScopedPointerPodDeleter> uri2(
                 ne_path_escape((_propagator->_remoteDir + _item._renameTarget).toUtf8()));
-            updateMTimeAndETag(uri2.data(), _item._modtime);
+            if (!updateMTimeAndETag(uri2.data(), _item._modtime))
+                return;
         }
     } else if (_item._file == QLatin1String("Shared") ) {
         // Check if it is the toplevel Shared folder and do not propagate it.
@@ -912,7 +911,8 @@ void PropagateRemoteRename::start()
             return;
         }
 
-        updateMTimeAndETag(uri2.data(), _item._modtime);
+        if (!updateMTimeAndETag(uri2.data(), _item._modtime))
+            return;
         emit progress(Progress::EndRename, _item, _item._size, _item._size);
     }
 
diff --git a/src/mirall/owncloudpropagator.h b/src/mirall/owncloudpropagator.h
index 56698d1..fba85ba 100644
--- a/src/mirall/owncloudpropagator.h
+++ b/src/mirall/owncloudpropagator.h
@@ -101,7 +101,11 @@ class PropagateItemJob : public PropagatorJob {
 protected:
     void done(SyncFileItem::Status status, const QString &errorString = QString());
 
-    void updateMTimeAndETag(const char *uri, time_t);
+    /* Issue a PROPPATCH and PROPFIND to update the mtime, and fetch the etag
+     * Return true in case of success, and false if the PROPFIND failed and the
+     * error has been reported
+     */
+    bool updateMTimeAndETag(const char* uri, time_t mtime);
 
     /* fetch the error code and string from the session
        in case of error, calls done with the error and returns true.

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