[Pkg-owncloud-commits] [owncloud-client] 128/211: SyncEngine: Refactor startSync() code
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:36 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 8b35cda4c683a68830c216056cff98b3e15fef3f
Author: Markus Goetz <markus at woboq.com>
Date: Mon Oct 20 15:51:50 2014 +0200
SyncEngine: Refactor startSync() code
---
src/mirall/syncengine.cpp | 67 +++++++++++++++++---------------------------
src/mirall/syncjournaldb.cpp | 1 +
2 files changed, 26 insertions(+), 42 deletions(-)
diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index 8951866..f507d69 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -525,54 +525,37 @@ void SyncEngine::startSync()
csync_resume(_csync_ctx);
- bool usingSelectiveSync = (!_selectiveSyncBlackList.isEmpty());
- qDebug() << (usingSelectiveSync ? "====Using Selective Sync" : "====NOT Using Selective Sync");
-
int fileRecordCount = -1;
if (!_journal->exists()) {
- fileRecordCount = _journal->getFileRecordCount(); // this creates the DB
- _journal->close(); // Close again so it doesn't interfere with the sync in the the other thread in csync_update
-
- if( fileRecordCount == -1 ) {
- // FIXME de-duplicate with logic below
- qDebug() << "No way to create a sync journal!";
- emit csyncError(tr("Unable to initialize a sync journal."));
- finalize();
- return;
- // database creation error!
- }
-
- qDebug() << "=====sync looks new (no DB exists), activating recursive PROPFIND if csync supports it";
- bool no_recursive_propfind = false;
- csync_set_module_property(_csync_ctx, "no_recursive_propfind", &no_recursive_propfind);
+ qDebug() << "=====sync looks new (no DB exists)";
} else {
- // retrieve the file count from the db and close it afterwards because
- // csync_update also opens the database.
+ qDebug() << "=====sync with existing DB";
+ }
- fileRecordCount = _journal->getFileRecordCount();
- bool isUpdateFrom_1_5 = _journal->isUpdateFrom_1_5();
- _journal->close();
+ 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 ) {
- // FIXME de-duplicate with logic above
- qDebug() << "No way to create a sync journal!";
- emit csyncError(tr("Unable to initialize a sync journal."));
- finalize();
- return;
- // database creation error!
- } else if ( fileRecordCount < 50 ) {
- qDebug() << "=====sync DB has only" << fileRecordCount << "items, enable recursive PROPFIND if csync supports it";
- bool no_recursive_propfind = false;
- csync_set_module_property(_csync_ctx, "no_recursive_propfind", &no_recursive_propfind);
- } else {
- qDebug() << "=====sync with existing DB";
- }
+ if( fileRecordCount == -1 ) {
+ qDebug() << "No way to create a sync journal!";
+ emit csyncError(tr("Unable to initialize a sync journal."));
+ finalize();
+ return;
+ // database creation error!
+ }
- if (fileRecordCount > 1 && isUpdateFrom_1_5) {
- qDebug() << "detected update from 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);
- }
+ if (fileRecordCount >= 1 && isUpdateFrom_1_5) {
+ qDebug() << "detected update from 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);
+ }
+
+ bool usingSelectiveSync = (!_selectiveSyncBlackList.isEmpty());
+ qDebug() << (usingSelectiveSync ? "====Using Selective Sync" : "====NOT Using Selective Sync");
+ if (fileRecordCount >= 0 && fileRecordCount < 50 && !usingSelectiveSync) {
+ qDebug() << "===== Activating recursive PROPFIND (currently" << fileRecordCount << "file records)";
+ bool no_recursive_propfind = false;
+ csync_set_module_property(_csync_ctx, "no_recursive_propfind", &no_recursive_propfind);
}
csync_set_userdata(_csync_ctx, this);
diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp
index 3a07869..c19d16c 100644
--- a/src/mirall/syncjournaldb.cpp
+++ b/src/mirall/syncjournaldb.cpp
@@ -99,6 +99,7 @@ bool SyncJournalDb::checkConnect()
return false;
}
+ // The database file is created by this call (SQLITE_OPEN_CREATE)
if( !_db.open(_dbFile) ) {
QString error = _db.error();
qDebug() << "Error opening the db: " << error;
--
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