[Pkg-owncloud-commits] [owncloud-client] 155/211: SyncJournalDB/SyncEngine: Properly detect 1.5 upgrade

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:40 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 a993496ab45505d61a1072b73e3bc2d33a098c77
Author: Markus Goetz <markus at woboq.com>
Date:   Tue Oct 21 20:25:15 2014 +0200

    SyncJournalDB/SyncEngine: Properly detect 1.5 upgrade
    
    Else we end up never reading file data from the DB.
---
 src/mirall/syncengine.cpp    |  4 +++-
 src/mirall/syncjournaldb.cpp | 12 +++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index fa53557..519c49e 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -544,9 +544,11 @@ void SyncEngine::startSync()
     }
 
     if (fileRecordCount >= 1 && isUpdateFrom_1_5) {
-        qDebug() << "detected update from 1.5";
+        qDebug() << "detected update from 1.5" << fileRecordCount << isUpdateFrom_1_5;
         // Disable the read from DB to be sure to re-read all the fileid and etags.
         csync_set_read_from_db(_csync_ctx, false);
+    } else {
+        csync_set_read_from_db(_csync_ctx, true);
     }
 
     bool usingSelectiveSync = (!_selectiveSyncBlackList.isEmpty());
diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp
index 71b3e9d..870cfdb 100644
--- a/src/mirall/syncjournaldb.cpp
+++ b/src/mirall/syncjournaldb.cpp
@@ -117,6 +117,8 @@ bool SyncJournalDb::checkConnect()
         return false;
     }
 
+    bool isNewDb = !QFile::exists(_dbFile);
+
     // The database file is created by this call (SQLITE_OPEN_CREATE)
     if( !_db.open(_dbFile) ) {
         QString error = _db.error();
@@ -235,10 +237,14 @@ bool SyncJournalDb::checkConnect()
         return sqlFail("Create table version", createQuery);
     }
 
+    _possibleUpgradeFromMirall_1_5 = false;
     SqlQuery versionQuery("SELECT major, minor FROM version;", _db);
     if (!versionQuery.next()) {
         // If there was no entry in the table, it means we are likely upgrading from 1.5
-        _possibleUpgradeFromMirall_1_5 = true;
+        if (!isNewDb) {
+            qDebug() << Q_FUNC_INFO << "_possibleUpgradeFromMirall_1_5 detected!";
+            _possibleUpgradeFromMirall_1_5 = true;
+        }
     } else {
         // Delete the existing entry so we can replace it by the new one
         createQuery.prepare("DELETE FROM version;");
@@ -622,6 +628,10 @@ bool SyncJournalDb::postSyncCleanup(const QSet<QString> &items )
     // Incoroporate results back into main DB
     walCheckpoint();
 
+    if (_possibleUpgradeFromMirall_1_5) {
+        _possibleUpgradeFromMirall_1_5 = false; // should be handled now
+    }
+
     return 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