[Pkg-owncloud-commits] [owncloud-client] 41/175: SyncEngine: Force re-read of folder Etags for upgrades from 1.8.0 and 1.8.1

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 e5e2ce2b22aacdc9e635c157c361db8e5d8fcb2c
Author: Markus Goetz <markus at woboq.com>
Date:   Wed May 13 12:54:49 2015 +0200

    SyncEngine: Force re-read of folder Etags for upgrades from 1.8.0 and 1.8.1
    
    This is a better fix than the previous one for the local-files-missing bug
    because it does not depend on the sync run to run fully through.
---
 src/libsync/syncengine.cpp    |  9 ++-------
 src/libsync/syncjournaldb.cpp | 32 ++++++++++++++++----------------
 src/libsync/syncjournaldb.h   |  2 --
 3 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index cfae321..9d3fbd7 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -605,17 +605,12 @@ void SyncEngine::startSync()
         // database creation error!
     }
 
-    bool isUpdateFrom_1_8 = _journal->isUpdateFrom_1_8_0();
-
     /*
      * 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.
      */
-    if (fileRecordCount >= 1 && (isUpdateFrom_1_5 || isUpdateFrom_1_8)) {
-        qDebug() << "detected update from 1.5 or 1.8" << fileRecordCount << isUpdateFrom_1_5;
+    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;
diff --git a/src/libsync/syncjournaldb.cpp b/src/libsync/syncjournaldb.cpp
index 599c676..3cee1ba 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), _possibleUpgradeFromMirall_1_8_0(false)
+    QObject(parent), _transaction(0), _possibleUpgradeFromMirall_1_5(false)
 {
 
     _dbFile = path;
@@ -273,7 +273,7 @@ bool SyncJournalDb::checkConnect()
     }
 
     _possibleUpgradeFromMirall_1_5 = false;
-    _possibleUpgradeFromMirall_1_8_0 = false;
+    bool possibleUpgradeFromMirall_1_8_0_or_1 = false;
 
     SqlQuery versionQuery("SELECT major, minor, patch FROM version;", _db);
     if (!versionQuery.next()) {
@@ -294,9 +294,9 @@ bool SyncJournalDb::checkConnect()
         int minor = versionQuery.intValue(1);
         int patch = versionQuery.intValue(2);
 
-        if( major == 1 && minor == 8 && patch  == 0 ) {
-            qDebug() << Q_FUNC_INFO << "_possibleUpgradeFromMirall_1_8_0 detected!";
-            _possibleUpgradeFromMirall_1_8_0 = true;
+        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;
         }
         // Not comparing the BUILD id here, correct?
         if( !(major == MIRALL_VERSION_MAJOR && minor == MIRALL_VERSION_MINOR && patch == MIRALL_VERSION_PATCH) ) {
@@ -323,6 +323,17 @@ bool SyncJournalDb::checkConnect()
         qDebug() << "WARN: Failed to update the database structure!";
     }
 
+    if (possibleUpgradeFromMirall_1_8_0_or_1) {
+        qDebug() << "Forcing remote re-discovery by deleting folder Etags";
+        SqlQuery deleteRemoteFolderEtagsQuery(_db);
+        deleteRemoteFolderEtagsQuery.prepare("UPDATE metadata SET md5=NULL WHERE type=2;");
+        if( !deleteRemoteFolderEtagsQuery.exec() ) {
+            qDebug() << "ERROR: Query failed" << deleteRemoteFolderEtagsQuery.error();
+        } else {
+            qDebug() << "Cleared" << deleteRemoteFolderEtagsQuery.numRowsAffected() << "folder ETags";
+        }
+    }
+
     _getFileRecordQuery.reset(new SqlQuery(_db));
     _getFileRecordQuery->prepare("SELECT path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm, filesize FROM "
                                  "metadata WHERE phash=?1" );
@@ -759,10 +770,6 @@ 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;
 }
 
@@ -1332,13 +1339,6 @@ 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 5fea8c1..eb3bc13 100644
--- a/src/libsync/syncjournaldb.h
+++ b/src/libsync/syncjournaldb.h
@@ -118,7 +118,6 @@ public:
      * are updated.
      */
     bool isUpdateFrom_1_5();
-    bool isUpdateFrom_1_8_0();
 
 private:
     bool updateDatabaseStructure();
@@ -136,7 +135,6 @@ 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