[Pkg-owncloud-commits] [owncloud-client] 08/14: SyncEngine: Handle upgrade case from 1.8.0

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed May 6 23:49:04 UTC 2015


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 d63abef718ebab0717c496dca11a9ad363bf6965
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Mon May 4 12:14:35 2015 +0200

    SyncEngine: Handle upgrade case from 1.8.0
    
    If 1.8.0 caused missing data in the local tree, this patch gets it
    back. For that, the usage of the journal for remote repository is
    disabled at the first start.
---
 src/libsync/syncengine.cpp    |  9 ++++++++-
 src/libsync/syncjournaldb.cpp | 16 ++++++++++++++++
 src/libsync/syncjournaldb.h   |  2 ++
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index 81d0872..29be34a 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -605,7 +605,14 @@ void SyncEngine::startSync()
         // database creation error!
     }
 
-    if (fileRecordCount >= 1 && isUpdateFrom_1_5) {
+    bool isUpdateFrom_1_8 = _journal->isUpdateFrom_1_8_0();
+
+    /*
+     * If 1.8.0 caused missing data in the local tree, this patch gets it
+     * back. For that, the usage of the journal for remote repository is
+     * disabled at the first start.
+     */
+    if (fileRecordCount >= 1 && (isUpdateFrom_1_5 || isUpdateFrom_1_8)) {
         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_ctx->read_remote_from_db = false;
diff --git a/src/libsync/syncjournaldb.cpp b/src/libsync/syncjournaldb.cpp
index 20d6edd..2ff589a 100644
--- a/src/libsync/syncjournaldb.cpp
+++ b/src/libsync/syncjournaldb.cpp
@@ -273,6 +273,8 @@ bool SyncJournalDb::checkConnect()
     }
 
     _possibleUpgradeFromMirall_1_5 = false;
+    _possibleUpgradeFromMirall_1_8_0 = false;
+
     SqlQuery versionQuery("SELECT major, minor, patch FROM version;", _db);
     if (!versionQuery.next()) {
         // If there was no entry in the table, it means we are likely upgrading from 1.5
@@ -292,6 +294,9 @@ bool SyncJournalDb::checkConnect()
         int minor = versionQuery.intValue(1);
         int patch = versionQuery.intValue(2);
 
+        if( major == 1 && minor == 8 && patch  == 0 ) {
+            _possibleUpgradeFromMirall_1_8_0 = true;
+        }
         // Not comparing the BUILD id here, correct?
         if( !(major == MIRALL_VERSION_MAJOR && minor == MIRALL_VERSION_MINOR && patch == MIRALL_VERSION_PATCH) ) {
             createQuery.prepare("UPDATE version SET major=?1, minor=?2, patch =?3, custom=?4 "
@@ -753,6 +758,10 @@ bool SyncJournalDb::postSyncCleanup(const QSet<QString>& filepathsToKeep,
         _possibleUpgradeFromMirall_1_5 = false; // should be handled now
     }
 
+    if (_possibleUpgradeFromMirall_1_8_0) {
+        _possibleUpgradeFromMirall_1_8_0 = false; // should be handled now
+    }
+
     return true;
 }
 
@@ -1322,6 +1331,13 @@ bool SyncJournalDb::isUpdateFrom_1_5()
     return _possibleUpgradeFromMirall_1_5;
 }
 
+bool SyncJournalDb::isUpdateFrom_1_8_0()
+{
+    QMutexLocker lock(&_mutex);
+    checkConnect();
+    return _possibleUpgradeFromMirall_1_8_0;
+}
+
 bool operator==(const SyncJournalDb::DownloadInfo & lhs,
                 const SyncJournalDb::DownloadInfo & rhs)
 {
diff --git a/src/libsync/syncjournaldb.h b/src/libsync/syncjournaldb.h
index eb3bc13..5fea8c1 100644
--- a/src/libsync/syncjournaldb.h
+++ b/src/libsync/syncjournaldb.h
@@ -118,6 +118,7 @@ public:
      * are updated.
      */
     bool isUpdateFrom_1_5();
+    bool isUpdateFrom_1_8_0();
 
 private:
     bool updateDatabaseStructure();
@@ -135,6 +136,7 @@ private:
     QMutex _mutex; // Public functions are protected with the mutex.
     int _transaction;
     bool _possibleUpgradeFromMirall_1_5;
+    bool _possibleUpgradeFromMirall_1_8_0;
     QScopedPointer<SqlQuery> _getFileRecordQuery;
     QScopedPointer<SqlQuery> _setFileRecordQuery;
     QScopedPointer<SqlQuery> _getDownloadInfoQuery;

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