[Pkg-owncloud-commits] [owncloud-client] 86/219: Restart the sync when we detect we need to redo a sync

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 11 14:43:13 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 a84b7dc27e43c9e9ef96fa8d25a561ee058f89c7
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Wed Sep 10 17:25:13 2014 +0200

    Restart the sync when we detect we need to redo a sync
    
    Fixes #1968
    Relates #2038
---
 src/mirall/folder.cpp             | 20 +++++++++++++++++---
 src/mirall/owncloudpropagator.cpp |  1 +
 src/mirall/owncloudpropagator.h   |  4 ++++
 src/mirall/propagator_qnam.cpp    |  1 +
 src/mirall/syncengine.cpp         |  4 ++++
 src/mirall/syncengine.h           |  5 +++++
 6 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index 8f46d63..a95c55c 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -269,6 +269,7 @@ void Folder::slotPollTimerTimeout()
     }
 
     if (quint64(_timeSinceLastSync.elapsed()) > MirallConfigFile().forceSyncInterval() ||
+            _lastEtag.isNull() ||
             !(_syncResult.status() == SyncResult::Success ||_syncResult.status() == SyncResult::Problem)) {
         qDebug() << "** Force Sync now, state is " << _syncResult.statusString();
         emit scheduleToSync(alias());
@@ -683,10 +684,13 @@ void Folder::slotSyncFinished()
 
     bubbleUpSyncResult();
 
-    _engine.reset(0);
+    bool anotherSyncNeeded = false;
+    if (_engine) {
+        anotherSyncNeeded = _engine->isAnotherSyncNeeded();
+        _engine.reset(0);
+    }
     // _watcher->setEventsEnabledDelayed(2000);
-    _pollTimer.start();
-    _timeSinceLastSync.restart();
+
 
 
     if (_csyncError) {
@@ -714,6 +718,16 @@ void Folder::slotSyncFinished()
     // all come in.
     QTimer::singleShot(200, this, SLOT(slotEmitFinishedDelayed() ));
 
+    if (!anotherSyncNeeded) {
+        _pollTimer.start();
+        _timeSinceLastSync.restart();
+    } else {
+        // Another sync is required.  We will make sure that the poll timer occurs soon enough
+        // and we clear the etag to force a sync
+        _lastEtag.clear();
+        QTimer::singleShot(1000, this, SLOT(slotPollTimerTimeout() ));
+    }
+
 }
 
 void Folder::slotEmitFinishedDelayed()
diff --git a/src/mirall/owncloudpropagator.cpp b/src/mirall/owncloudpropagator.cpp
index dd0a859..107d4e4 100644
--- a/src/mirall/owncloudpropagator.cpp
+++ b/src/mirall/owncloudpropagator.cpp
@@ -150,6 +150,7 @@ bool PropagateItemJob::checkForProblemsWithShared(int httpStatusCode, const QStr
             // Also remove the inodes and fileid from the db so no further renames are tried for
             // this item.
             _propagator->_journal->avoidRenamesOnNextSync(_item._file);
+            _propagator->_anotherSyncNeeded = true;
         }
         if( newJob )  {
             newJob->setRestoreJobMsg(msg);
diff --git a/src/mirall/owncloudpropagator.h b/src/mirall/owncloudpropagator.h
index 185ee60..b1e3fab 100644
--- a/src/mirall/owncloudpropagator.h
+++ b/src/mirall/owncloudpropagator.h
@@ -206,6 +206,7 @@ public:
             , _journal(progressDb)
             , _finishedEmited(false)
             , _activeJobs(0)
+            , _anotherSyncNeeded(false)
     { }
 
     void start(const SyncFileItemVector &_syncedItems);
@@ -218,6 +219,9 @@ public:
     /* The number of currently active jobs */
     int _activeJobs;
 
+    /** We detected that another sync is required after this one */
+    bool _anotherSyncNeeded;
+
     bool isInSharedDirectory(const QString& file);
     bool localFileNameClash(const QString& relfile);
     QString getFilePath(const QString& tmp_file_name) const;
diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index 0dd148d..e44d641 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -319,6 +319,7 @@ void PropagateUploadFileQNAM::slotPutFinished()
             qDebug() << "The local file has changed during upload:" << _item._modtime << "!=" << new_mtime
                      << ", QFileInfo: " << Utility::qDateTimeToTime_t(fi.lastModified()) << fi.lastModified();
             _propagator->_activeJobs--;
+            _propagator->_anotherSyncNeeded = true;
             done(SyncFileItem::SoftError, tr("Local file changed during sync."));
             // FIXME:  the legacy code was retrying for a few seconds.
             //         and also checking that after the last chunk, and removed the file in case of INSTRUCTION_NEW
diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index 272de6e..cd668af 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -59,6 +59,7 @@ SyncEngine::SyncEngine(CSYNC *ctx, const QString& localPath, const QString& remo
   , _hasRemoveFile(false)
   , _uploadLimit(0)
   , _downloadLimit(0)
+  , _anotherSyncNeeded(false)
 {
     qRegisterMetaType<SyncFileItem>("SyncFileItem");
     qRegisterMetaType<SyncFileItem::Status>("SyncFileItem::Status");
@@ -762,6 +763,8 @@ void SyncEngine::slotJobCompleted(const SyncFileItem &item)
 
 void SyncEngine::slotFinished()
 {
+    _anotherSyncNeeded = _anotherSyncNeeded || _propagator->_anotherSyncNeeded;
+
     // emit the treewalk results.
     if( ! _journal->postSyncCleanup( _seenFiles ) ) {
         qDebug() << "Cleaning of synced ";
@@ -973,6 +976,7 @@ void SyncEngine::checkForPermission()
                     //  At this point we would need to go back to the propagate phase on both remote to take
                     //  the decision.
                     _journal->avoidRenamesOnNextSync(it->_file);
+                    _anotherSyncNeeded = true;
 
 
                     if (it->_isDirectory) {
diff --git a/src/mirall/syncengine.h b/src/mirall/syncengine.h
index 9806cc6..b42ed2c 100644
--- a/src/mirall/syncengine.h
+++ b/src/mirall/syncengine.h
@@ -64,6 +64,9 @@ public:
     void setSelectiveSyncBlackList(const QStringList &list)
     { _selectiveSyncBlackList = list; }
 
+    /* Return true if we detected that another sync is needed to complete the sync */
+    bool isAnotherSyncNeeded() { return _anotherSyncNeeded; }
+
 signals:
     void csyncError( const QString& );
     void csyncUnavailable();
@@ -160,6 +163,8 @@ private:
     QHash<QString, QByteArray> _remotePerms;
 
     QStringList _selectiveSyncBlackList;
+
+    bool _anotherSyncNeeded;
 };
 
 }

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