[Pkg-owncloud-commits] [owncloud-client] 129/211: SyncEngine/SyncJournalDB: Don't keep transactions open

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:37 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 7dbb98c2e58e2d11642f99f50c46896af3d1d70b
Author: Markus Goetz <markus at woboq.com>
Date:   Mon Oct 20 16:50:55 2014 +0200

    SyncEngine/SyncJournalDB: Don't keep transactions open
---
 src/mirall/syncengine.cpp    | 20 +++++++++++---------
 src/mirall/syncjournaldb.cpp | 13 ++++++-------
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index f507d69..23458f5 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -534,7 +534,6 @@ void SyncEngine::startSync()
 
     fileRecordCount = _journal->getFileRecordCount(); // this creates the DB if it does not exist yet
     bool isUpdateFrom_1_5 = _journal->isUpdateFrom_1_5();
-    _journal->close(); // Close again so it doesn't interfere with the sync in the the other thread in csync_update
 
     if( fileRecordCount == -1 ) {
         qDebug() << "No way to create a sync journal!";
@@ -611,6 +610,17 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
     }
     qDebug() << "<<#### Discovery end #################################################### " << _stopWatch.addLapTime(QLatin1String("Discovery Finished"));
 
+    // Sanity check
+    if (!_journal->isConnected()) {
+        qDebug() << "Bailing out, DB failure";
+        emit csyncError(tr("Cannot open the sync journal"));
+        finalize();
+        return;
+    } else {
+        // Commits a possibly existing (should not though) transaction and starts a new one for the propagate phase
+        _journal->commit("pre Propagate");
+    }
+
     if( csync_reconcile(_csync_ctx) < 0 ) {
         handleSyncError(_csync_ctx, "csync_reconcile");
         return;
@@ -648,14 +658,6 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
     // make sure everything is allowed
     checkForPermission();
 
-    // Sanity check
-    if (!_journal->isConnected()) {
-        qDebug() << "Bailing out, DB failure";
-        emit csyncError(tr("Cannot open the sync journal"));
-        finalize();
-        return;
-    }
-
     // To announce the beginning of the sync
     emit aboutToPropagate(_syncedItems);
     _progressInfo._completedFileCount = ULLONG_MAX; // indicate the start with max
diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp
index c19d16c..128714f 100644
--- a/src/mirall/syncjournaldb.cpp
+++ b/src/mirall/syncjournaldb.cpp
@@ -207,14 +207,9 @@ bool SyncJournalDb::checkConnect()
     if (!versionQuery.next()) {
         // If there was no entry in the table, it means we are likely upgrading from 1.5
         _possibleUpgradeFromMirall_1_5 = true;
-    } else {
-        // Delete the existing entry so we can replace it by the new one
-        createQuery.prepare("DELETE FROM version;");
-        if (!createQuery.exec()) {
-            return sqlFail("Remove version", createQuery);
-        }
     }
-    createQuery.prepare("INSERT INTO version (major, minor, patch) VALUES ( ?1, ?2 , ?3 );");
+
+    createQuery.prepare("INSERT OR REPLACE INTO version (major, minor, patch) VALUES ( ?1, ?2 , ?3 );");
     createQuery.bindValue(1, MIRALL_VERSION_MAJOR);
     createQuery.bindValue(2, MIRALL_VERSION_MINOR);
     createQuery.bindValue(3, MIRALL_VERSION_PATCH);
@@ -279,12 +274,16 @@ bool SyncJournalDb::checkConnect()
     _blacklistQuery.reset(new SqlQuery(_db));
     _blacklistQuery->prepare(sql);
 
+    // don't start a new transaction now
+    commitInternal(QString("checkConnect End"), false);
+
     return rc;
 }
 
 void SyncJournalDb::close()
 {
     QMutexLocker locker(&_mutex);
+    qDebug() << Q_FUNC_INFO << _dbFile;
 
     commitTransaction();
 

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