Merge pull request #2188 from nextcloud/upgrade-syncjournaldb-to27

Move existing syncjournal db files from client ver <2.7
This commit is contained in:
Kevin Ottens 2020-07-13 18:04:28 +02:00 committed by GitHub
commit 62e2f64165
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -218,13 +218,27 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account,
socketApi()->slotUnregisterPath(folderAlias);
auto settings = account->settings();
auto journalFileMoveSuccess = true;
// Due to db logic can't be sure which of these file exist.
if (oldJournal.exists()) {
journalFileMoveSuccess &= oldJournal.rename(folderDefinition.journalPath);
}
if (oldJournalShm.exists()) {
journalFileMoveSuccess &= oldJournalShm.rename(folderDefinition.journalPath.append("-shm"));
}
if (oldJournalWal.exists()) {
journalFileMoveSuccess &= oldJournalWal.rename(folderDefinition.journalPath.append("-wal"));
}
if (!journalFileMoveSuccess) {
qCWarning(lcFolderMan) << "Wasn't able to move pre-2.7 syncjournal database files to new location. One-time loss off sync settings possible.";
} else {
qCInfo(lcFolderMan) << "Successfully migrated syncjournal database.";
}
Folder *f = addFolderInternal(folderDefinition, account.data());
f->saveToSettings();
oldJournal.remove();
oldJournalShm.remove();
oldJournalWal.remove();
return;
}