[Pkg-owncloud-commits] [owncloud-client] 273/333: Fix some error cases in the SyncEngine

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Apr 17 23:17:03 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 bfe6a50b19c2f6d7bc6e7d1146c2a90cd7fa5c65
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Tue Apr 1 13:41:47 2014 +0200

    Fix some error cases in the SyncEngine
    
    Always cleanup properly when we bail out.
    
    Also fix thread safety of the SyncJournalDB
---
 src/mirall/syncengine.cpp    | 10 ++++++++--
 src/mirall/syncjournaldb.cpp |  7 +++++++
 src/mirall/syncjournaldb.h   | 12 +++++++++++-
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index 0c931c6..9e088af 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -530,9 +530,12 @@ void SyncEngine::slotUpdateFinished(int updateResult)
     }
 
     // Sanity check
-    if (!_journal->checkConnect()) {
+    if (!_journal->isConnected()) {
         qDebug() << "Bailing out, DB failure";
-        QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection); // signal
+        emit csyncError(tr("Cannot open the sync journal"));
+        emit finished();
+        _syncMutex.unlock();
+        _thread.quit();
         return;
     }
 
@@ -546,6 +549,9 @@ void SyncEngine::slotUpdateFinished(int updateResult)
         emit aboutToRemoveAllFiles(_syncedItems.first()._direction, &cancel);
         if (cancel) {
             qDebug() << Q_FUNC_INFO << "Abort sync";
+            emit finished();
+            _syncMutex.unlock();
+            _thread.quit();
             return;
         }
     }
diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp
index 8b71c37..cb5d828 100644
--- a/src/mirall/syncjournaldb.cpp
+++ b/src/mirall/syncjournaldb.cpp
@@ -819,5 +819,12 @@ SyncJournalDb::~SyncJournalDb()
     close();
 }
 
+bool SyncJournalDb::isConnected()
+{
+    QMutexLocker lock(&_mutex);
+    return checkConnect();
+}
+
+
 
 } // namespace Mirall
diff --git a/src/mirall/syncjournaldb.h b/src/mirall/syncjournaldb.h
index f6f80bf..b900423 100644
--- a/src/mirall/syncjournaldb.h
+++ b/src/mirall/syncjournaldb.h
@@ -25,6 +25,11 @@ namespace Mirall {
 class SyncJournalFileRecord;
 class SyncJournalBlacklistRecord;
 
+/**
+ * Class that handle the sync database
+ *
+ * This class is thread safe. All public function are locking the mutex.
+ */
 class SyncJournalDb : public QObject
 {
     Q_OBJECT
@@ -75,7 +80,11 @@ public:
 
     void close();
 
-    bool checkConnect();
+    /**
+     * return true if everything is correct
+     */
+    bool isConnected();
+
 
 
 
@@ -91,6 +100,7 @@ private:
     void startTransaction();
     void commitTransaction();
     QStringList tableColumns( const QString& table );
+    bool checkConnect();
 
     QSqlDatabase _db;
     QString _dbFile;

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