Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kamm <mail@ckamm.de>2018-05-14 15:37:48 +0300
committerKevin Ottens <kevin.ottens@nextcloud.com>2020-12-15 12:57:54 +0300
commit97f7b5abeb08f7c136de9c45b60a610e963ff733 (patch)
treefe75802e0ca0bae1b9f2af05091495fafe5e11ea /src/gui/application.cpp
parent87ba4e6b9cde0cbc077de1217072a311733a03c0 (diff)
Settings migration: Preserve future settings where possible
See discussion in #6506
Diffstat (limited to 'src/gui/application.cpp')
-rw-r--r--src/gui/application.cpp84
1 files changed, 50 insertions, 34 deletions
diff --git a/src/gui/application.cpp b/src/gui/application.cpp
index 306eeb181..b1910be3c 100644
--- a/src/gui/application.cpp
+++ b/src/gui/application.cpp
@@ -102,47 +102,63 @@ namespace {
// ----------------------------------------------------------------------------------
-bool Application::configBackwardMigration()
+bool Application::configVersionMigration()
{
- auto accountKeys = AccountManager::backwardMigrationKeys();
- auto folderKeys = FolderMan::backwardMigrationKeys();
+ QStringList deleteKeys, ignoreKeys;
+ AccountManager::backwardMigrationSettingsKeys(&deleteKeys, &ignoreKeys);
+ FolderMan::backwardMigrationSettingsKeys(&deleteKeys, &ignoreKeys);
- bool containsFutureData = !accountKeys.isEmpty() || !folderKeys.isEmpty();
+ ConfigFile configFile;
- // Deal with unreadable accounts
- if (!containsFutureData)
+ // Did the client version change?
+ // (The client version is adjusted further down)
+ bool versionChanged = configFile.clientVersionString() != MIRALL_VERSION_STRING;
+
+ // We want to message the user either for destructive changes,
+ // or if we're ignoring something and the client version changed.
+ bool warningMessage = !deleteKeys.isEmpty() || (!ignoreKeys.isEmpty() && versionChanged);
+
+ if (!versionChanged && !warningMessage)
return true;
- const auto backupFile = ConfigFile().backup();
-
- QMessageBox box(
- QMessageBox::Warning,
- APPLICATION_SHORTNAME,
- tr("Some settings were configured in newer versions of this client and "
- "use features that are not available in this version.<br>"
- "<br>"
- "<b>Continuing will mean losing these settings.</b><br>"
- "<br>"
- "The current configuration file was already backed up to <i>%1</i>.")
- .arg(backupFile));
- box.addButton(tr("Quit"), QMessageBox::AcceptRole);
- auto continueBtn = box.addButton(tr("Continue"), QMessageBox::DestructiveRole);
-
- box.exec();
- if (box.clickedButton() != continueBtn) {
- QTimer::singleShot(0, qApp, SLOT(quit()));
- return false;
- }
+ const auto backupFile = configFile.backup();
+
+ if (warningMessage) {
+ QString boldMessage;
+ if (!deleteKeys.isEmpty()) {
+ boldMessage = tr("Continuing will mean <b>deleting these settings</b>.");
+ } else {
+ boldMessage = tr("Continuing will mean <b>ignoring these settings</b>.");
+ }
- auto settings = ConfigFile::settingsWithGroup("foo");
- settings->endGroup();
+ QMessageBox box(
+ QMessageBox::Warning,
+ APPLICATION_SHORTNAME,
+ tr("Some settings were configured in newer versions of this client and "
+ "use features that are not available in this version.<br>"
+ "<br>"
+ "%1<br>"
+ "<br>"
+ "The current configuration file was already backed up to <i>%2</i>.")
+ .arg(boldMessage, backupFile));
+ box.addButton(tr("Quit"), QMessageBox::AcceptRole);
+ auto continueBtn = box.addButton(tr("Continue"), QMessageBox::DestructiveRole);
+
+ box.exec();
+ if (box.clickedButton() != continueBtn) {
+ QTimer::singleShot(0, qApp, SLOT(quit()));
+ return false;
+ }
- // Wipe the keys from the future
- for (const auto &badKey : accountKeys)
- settings->remove(badKey);
- for (const auto &badKey : folderKeys)
- settings->remove(badKey);
+ auto settings = ConfigFile::settingsWithGroup("foo");
+ settings->endGroup();
+
+ // Wipe confusing keys from the future, ignore the others
+ for (const auto &badKey : deleteKeys)
+ settings->remove(badKey);
+ }
+ configFile.setClientVersionString(MIRALL_VERSION_STRING);
return true;
}
@@ -231,7 +247,7 @@ Application::Application(int &argc, char **argv)
setupLogging();
setupTranslations();
- if (!configBackwardMigration()) {
+ if (!configVersionMigration()) {
return;
}