From 88e0c66d0bd4b33fc1e007f1985e28b9d3b270f5 Mon Sep 17 00:00:00 2001 From: Camila Date: Tue, 15 Aug 2023 18:20:18 +0200 Subject: [PATCH] Add {} for single line condition, const auto and fix comments. Signed-off-by: Camila --- src/gui/accountmanager.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 205a8007c98f2..792665843fdc6 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -105,8 +105,9 @@ AccountManager::AccountsRestoreResult AccountManager::restore(const bool alsoRes if (auto accState = AccountState::loadFromSettings(acc, *settings)) { auto jar = qobject_cast(acc->_am->cookieJar()); ASSERT(jar); - if (jar) + if (jar) { jar->restore(acc->cookieJarPath()); + } addAccountState(accState); } } @@ -328,8 +329,9 @@ void AccountManager::saveAccountHelper(Account *acc, QSettings &settings, bool s settings.setValue(QLatin1String(authTypeC), acc->_credentials->authType()); // HACK: Save http_user also as user - if (acc->_settingsMap.contains(httpUserC)) + if (acc->_settingsMap.contains(httpUserC)) { settings.setValue(userC, acc->_settingsMap.value(httpUserC)); + } } // Save accepted certificates. @@ -372,8 +374,8 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings) auto authType = settings.value(QLatin1String(authTypeC)).toString(); // There was an account-type saving bug when 'skip folder config' was used - // See #5408. This attempts to fix up the "dummy" authType - if (authType == QLatin1String(dummyAuthTypeC)) { + // See owncloud#5408. This attempts to fix up the "dummy" or empty authType + if (authType == QLatin1String(dummyAuthTypeC) || authType.isEmpty()) { if (settings.contains(QLatin1String(httpUserC))) { authType = httpAuthTypeC; } else if (settings.contains(QLatin1String(shibbolethUserC))) { @@ -401,8 +403,10 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings) const auto settingsChildKeys = settings.childKeys(); for (const auto &key : settingsChildKeys) { - if (!key.startsWith(httpAuthPrefix)) + if (!key.startsWith(httpAuthPrefix)) { continue; + } + const auto newkey = QString::fromLatin1(webflowAuthPrefix).append(key.mid(5)); settings.setValue(newkey, settings.value((key))); settings.remove(key); @@ -415,14 +419,14 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings) acc->_skipE2eeMetadataChecksumValidation = settings.value(QLatin1String(skipE2eeMetadataChecksumValidationC), {}).toBool(); acc->_davUser = settings.value(QLatin1String(davUserC), "").toString(); - // We want to only restore settings for that auth type and the user value acc->_settingsMap.insert(QLatin1String(userC), settings.value(userC)); acc->_displayName = settings.value(QLatin1String(displayNameC), "").toString(); - QString authTypePrefix = authType + "_"; + const auto authTypePrefix = authType + "_"; const auto settingsChildKeys = settings.childKeys(); for (const auto &key : settingsChildKeys) { - if (!key.startsWith(authTypePrefix)) + if (!key.startsWith(authTypePrefix)) { continue; + } acc->_settingsMap.insert(key, settings.value(key)); }