From cb36a37779161b46c2401f973c9f51d548969959 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 20 Oct 2014 14:25:22 +0200 Subject: [PATCH] SyncEngine/SyncJournalDB: Fix creation of .csync_journal --- src/mirall/syncengine.cpp | 19 ++++++++++++++++++- src/mirall/syncjournaldb.cpp | 9 +++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp index 1458d3dfe..895186606 100644 --- a/src/mirall/syncengine.cpp +++ b/src/mirall/syncengine.cpp @@ -525,19 +525,36 @@ 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); } else { // retrieve the file count from the db and close it afterwards because // csync_update also opens the database. - int fileRecordCount = 0; + fileRecordCount = _journal->getFileRecordCount(); bool isUpdateFrom_1_5 = _journal->isUpdateFrom_1_5(); _journal->close(); 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(); diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp index dd34deadc..3a07869eb 100644 --- a/src/mirall/syncjournaldb.cpp +++ b/src/mirall/syncjournaldb.cpp @@ -94,8 +94,8 @@ bool SyncJournalDb::checkConnect() return true; } - if( _dbFile.isEmpty() || !QFile::exists(_dbFile) ) { - qDebug() << "Database " + _dbFile + " is empty or does not exist"; + if( _dbFile.isEmpty()) { + qDebug() << "Database filename" + _dbFile + " is empty"; return false; } @@ -105,6 +105,11 @@ bool SyncJournalDb::checkConnect() return false; } + if( !QFile::exists(_dbFile) ) { + qDebug() << "Database file" + _dbFile + " does not exist"; + return false; + } + SqlQuery pragma1(_db); pragma1.prepare("SELECT sqlite_version();"); if (!pragma1.exec()) {