#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!";
// 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.
namespace OCC {
SyncJournalDb::SyncJournalDb(const QString& path, QObject *parent) :
- QObject(parent), _transaction(0), _possibleUpgradeFromMirall_1_5(false)
+ QObject(parent), _transaction(0)
{
_dbFile = path;
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);
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) ) {
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;");
_deleteFileRecordRecursively.reset(0);
_getErrorBlacklistQuery.reset(0);
_setErrorBlacklistQuery.reset(0);
- _possibleUpgradeFromMirall_1_5 = false;
_db.close();
_avoidReadFromDbOnNextSyncFilter.clear();
// Incoroporate results back into main DB
walCheckpoint();
- if (_possibleUpgradeFromMirall_1_5) {
- _possibleUpgradeFromMirall_1_5 = false; // should be handled now
- }
-
return true;
}
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)
{