[Pkg-owncloud-commits] [owncloud-client] 42/175: SyncJournalDB: Simplify code

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Aug 8 10:36:25 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 3556ed416c514e14374e7911bf39b4ec8aa6f1ba
Author: Markus Goetz <markus at woboq.com>
Date:   Wed May 13 13:15:53 2015 +0200

    SyncJournalDB: Simplify code
---
 src/libsync/syncengine.cpp    | 12 +-----------
 src/libsync/syncjournaldb.cpp | 33 ++++++++++++++-------------------
 src/libsync/syncjournaldb.h   |  7 -------
 3 files changed, 15 insertions(+), 37 deletions(-)

diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index 9d3fbd7..f1307ac 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -595,7 +595,6 @@ void SyncEngine::startSync()
 #endif
 
     fileRecordCount = _journal->getFileRecordCount(); // this creates the DB if it does not exist yet
-    bool isUpdateFrom_1_5 = _journal->isUpdateFrom_1_5();
 
     if( fileRecordCount == -1 ) {
         qDebug() << "No way to create a sync journal!";
@@ -605,16 +604,7 @@ void SyncEngine::startSync()
         // database creation error!
     }
 
-    /*
-     * If we are upgrading from a client version older than 1.5 is found,
-     * we cannot read from the database because we need to fetch the files id and etags.
-     */
-    if (fileRecordCount >= 1 && isUpdateFrom_1_5) {
-        qDebug() << "detected update from 1.5" << fileRecordCount << isUpdateFrom_1_5;
-        _csync_ctx->read_remote_from_db = false;
-    } else {
-        _csync_ctx->read_remote_from_db = true;
-    }
+    _csync_ctx->read_remote_from_db = true;
 
     // This tells csync to never read from the DB if it is empty
     // thereby speeding up the initial discovery significantly.
diff --git a/src/libsync/syncjournaldb.cpp b/src/libsync/syncjournaldb.cpp
index 3cee1ba..9c35269 100644
--- a/src/libsync/syncjournaldb.cpp
+++ b/src/libsync/syncjournaldb.cpp
@@ -30,7 +30,7 @@
 namespace OCC {
 
 SyncJournalDb::SyncJournalDb(const QString& path, QObject *parent) :
-    QObject(parent), _transaction(0), _possibleUpgradeFromMirall_1_5(false)
+    QObject(parent), _transaction(0)
 {
 
     _dbFile = path;
@@ -272,15 +272,14 @@ bool SyncJournalDb::checkConnect()
         return sqlFail("Create table version", createQuery);
     }
 
-    _possibleUpgradeFromMirall_1_5 = false;
-    bool possibleUpgradeFromMirall_1_8_0_or_1 = false;
+    bool forceRemoteDiscovery = 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
         if (!isNewDb) {
-            qDebug() << Q_FUNC_INFO << "_possibleUpgradeFromMirall_1_5 detected!";
-            _possibleUpgradeFromMirall_1_5 = true;
+            qDebug() << Q_FUNC_INFO << "possibleUpgradeFromMirall_1_5 detected!";
+            forceRemoteDiscovery = true;
         }
         createQuery.prepare("INSERT INTO version VALUES (?1, ?2, ?3, ?4);");
         createQuery.bindValue(1, MIRALL_VERSION_MAJOR);
@@ -296,7 +295,7 @@ bool SyncJournalDb::checkConnect()
 
         if( major == 1 && minor == 8 && (patch == 0 || patch == 1) ) {
             qDebug() << Q_FUNC_INFO << "possibleUpgradeFromMirall_1_8_0_or_1 detected!";
-            possibleUpgradeFromMirall_1_8_0_or_1 = true;
+            forceRemoteDiscovery = true;
         }
         // Not comparing the BUILD id here, correct?
         if( !(major == MIRALL_VERSION_MAJOR && minor == MIRALL_VERSION_MINOR && patch == MIRALL_VERSION_PATCH) ) {
@@ -323,7 +322,15 @@ bool SyncJournalDb::checkConnect()
         qDebug() << "WARN: Failed to update the database structure!";
     }
 
-    if (possibleUpgradeFromMirall_1_8_0_or_1) {
+    /*
+     * If we are upgrading from a client version older than 1.5 is found,
+     * we cannot read from the database because we need to fetch the files id and etags.
+     *
+     *  If 1.8.0 caused missing data in the local tree, so we also don't read from DB
+     *  to get back the files that were gone.
+     *  In 1.8.1 we had a fix to re-get the data, but this one here is better
+     */
+    if (forceRemoteDiscovery) {
         qDebug() << "Forcing remote re-discovery by deleting folder Etags";
         SqlQuery deleteRemoteFolderEtagsQuery(_db);
         deleteRemoteFolderEtagsQuery.prepare("UPDATE metadata SET md5=NULL WHERE type=2;");
@@ -420,7 +427,6 @@ void SyncJournalDb::close()
     _deleteFileRecordRecursively.reset(0);
     _getErrorBlacklistQuery.reset(0);
     _setErrorBlacklistQuery.reset(0);
-    _possibleUpgradeFromMirall_1_5 = false;
 
     _db.close();
     _avoidReadFromDbOnNextSyncFilter.clear();
@@ -766,10 +772,6 @@ bool SyncJournalDb::postSyncCleanup(const QSet<QString>& filepathsToKeep,
     // Incoroporate results back into main DB
     walCheckpoint();
 
-    if (_possibleUpgradeFromMirall_1_5) {
-        _possibleUpgradeFromMirall_1_5 = false; // should be handled now
-    }
-
     return true;
 }
 
@@ -1332,13 +1334,6 @@ bool SyncJournalDb::isConnected()
     return checkConnect();
 }
 
-bool SyncJournalDb::isUpdateFrom_1_5()
-{
-    QMutexLocker lock(&_mutex);
-    checkConnect();
-    return _possibleUpgradeFromMirall_1_5;
-}
-
 bool operator==(const SyncJournalDb::DownloadInfo & lhs,
                 const SyncJournalDb::DownloadInfo & rhs)
 {
diff --git a/src/libsync/syncjournaldb.h b/src/libsync/syncjournaldb.h
index eb3bc13..6074631 100644
--- a/src/libsync/syncjournaldb.h
+++ b/src/libsync/syncjournaldb.h
@@ -113,12 +113,6 @@ public:
      */
     bool isConnected();
 
-    /**
-     * Tell the sync engine if we need to disable the fetch from db to be sure that the fileid
-     * are updated.
-     */
-    bool isUpdateFrom_1_5();
-
 private:
     bool updateDatabaseStructure();
     bool updateMetadataTableStructure();
@@ -134,7 +128,6 @@ private:
     QString _dbFile;
     QMutex _mutex; // Public functions are protected with the mutex.
     int _transaction;
-    bool _possibleUpgradeFromMirall_1_5;
     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