SyncEngine: Handle upgrade case from 1.8.0

If 1.8.0 caused missing data in the local tree, this patch gets it
back. For that, the usage of the journal for remote repository is
disabled at the first start.
This commit is contained in:
Klaas Freitag 2015-05-04 12:14:35 +02:00
parent cdba8a7f2f
commit d63abef718
3 changed files with 26 additions and 1 deletions

View file

@ -605,7 +605,14 @@ void SyncEngine::startSync()
// database creation error!
}
if (fileRecordCount >= 1 && isUpdateFrom_1_5) {
bool isUpdateFrom_1_8 = _journal->isUpdateFrom_1_8_0();
/*
* If 1.8.0 caused missing data in the local tree, this patch gets it
* back. For that, the usage of the journal for remote repository is
* disabled at the first start.
*/
if (fileRecordCount >= 1 && (isUpdateFrom_1_5 || isUpdateFrom_1_8)) {
qDebug() << "detected update from 1.5" << fileRecordCount << isUpdateFrom_1_5;
// Disable the read from DB to be sure to re-read all the fileid and etags.
_csync_ctx->read_remote_from_db = false;

View file

@ -273,6 +273,8 @@ bool SyncJournalDb::checkConnect()
}
_possibleUpgradeFromMirall_1_5 = false;
_possibleUpgradeFromMirall_1_8_0 = 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
@ -292,6 +294,9 @@ bool SyncJournalDb::checkConnect()
int minor = versionQuery.intValue(1);
int patch = versionQuery.intValue(2);
if( major == 1 && minor == 8 && patch == 0 ) {
_possibleUpgradeFromMirall_1_8_0 = true;
}
// Not comparing the BUILD id here, correct?
if( !(major == MIRALL_VERSION_MAJOR && minor == MIRALL_VERSION_MINOR && patch == MIRALL_VERSION_PATCH) ) {
createQuery.prepare("UPDATE version SET major=?1, minor=?2, patch =?3, custom=?4 "
@ -753,6 +758,10 @@ 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;
}
@ -1322,6 +1331,13 @@ 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)
{

View file

@ -118,6 +118,7 @@ public:
* are updated.
*/
bool isUpdateFrom_1_5();
bool isUpdateFrom_1_8_0();
private:
bool updateDatabaseStructure();
@ -135,6 +136,7 @@ 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;