Преглед на файлове

AccountSettings: Restore from legacy only once #3565

And also introduce a Accounts/version int at the same time. That
may make future account settings migrations easier to manage.
Christian Kamm преди 10 години
родител
ревизия
419deff861
променени са 1 файла, в които са добавени 4 реда и са изтрити 1 реда
  1. 4 1
      src/gui/accountmanager.cpp

+ 4 - 1
src/gui/accountmanager.cpp

@@ -29,6 +29,7 @@ static const char userC[] = "user";
 static const char httpUserC[] = "http_user";
 static const char caCertsKeyC[] = "CaCertificates";
 static const char accountsC[] = "Accounts";
+static const char versionC[] = "version";
 }
 
 
@@ -45,7 +46,8 @@ bool AccountManager::restore()
     auto settings = Account::settingsWithGroup(QLatin1String(accountsC));
 
     // If there are no accounts, check the old format.
-    if (settings->childGroups().isEmpty()) {
+    if (settings->childGroups().isEmpty()
+            && !settings->contains(QLatin1String(versionC))) {
         return restoreFromLegacySettings();
     }
 
@@ -122,6 +124,7 @@ bool AccountManager::restoreFromLegacySettings()
 void AccountManager::save(bool saveCredentials)
 {
     auto settings = Account::settingsWithGroup(QLatin1String(accountsC));
+    settings->setValue(QLatin1String(versionC), 2);
     foreach (const auto &acc, _accounts) {
         settings->beginGroup(acc->account()->id());
         save(acc->account(), *settings, saveCredentials);