More concisely clean paths of trailing slash URLs in restore old config migration...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 11 Jan 2023 15:58:48 +0000 (16:58 +0100)
committerClaudio Cambra <claudio.cambra@gmail.com>
Mon, 23 Jan 2023 15:29:01 +0000 (16:29 +0100)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/accountmanager.cpp

index 41ad72efe1ccb27c35b8228af8ec999225c76a61..adb0fd04fee269dabb31eb071ae2662c0efa5fc0 100644 (file)
@@ -182,22 +182,19 @@ bool AccountManager::restoreFromLegacySettings()
                 }
 
                 // Check the theme url to see if it is the same url that the oC config was for
-                auto overrideUrl = Theme::instance()->overrideServerUrl();
-                qCInfo(lcAccountManager) << "Migrate: overrideUrl" << overrideUrl;
-                if (!overrideUrl.isEmpty()) {
-                    if (overrideUrl.endsWith('/')) {
-                        overrideUrl.chop(1);
-                    }
-                    auto oCUrl = oCSettings->value(QLatin1String(urlC)).toString();
-                    if (oCUrl.endsWith('/')) {
-                        oCUrl.chop(1);
-                    }
+                const auto overrideUrl = Theme::instance()->overrideServerUrl();
+                const auto cleanOverrideUrl = overrideUrl.endsWith('/') ? overrideUrl.chopped(1) : overrideUrl;
+                qCInfo(lcAccountManager) << "Migrate: overrideUrl" << cleanOverrideUrl;
+
+                if (!cleanOverrideUrl.isEmpty()) {
+                    const auto oCUrl = oCSettings->value(QLatin1String(urlC)).toString();
+                    const auto cleanOCUrl = oCUrl.endsWith('/') ? oCUrl.chopped(1) : oCUrl;
 
                     // in case the urls are equal reset the settings object to read from
                     // the ownCloud settings object
-                    qCInfo(lcAccountManager) << "Migrate oC config if " << oCUrl << " == " << overrideUrl << ":"
-                                             << (oCUrl == overrideUrl ? "Yes" : "No");
-                    if (oCUrl == overrideUrl) {
+                    qCInfo(lcAccountManager) << "Migrate oC config if " << cleanOCUrl << " == " << cleanOverrideUrl << ":"
+                                             << (cleanOCUrl == cleanOverrideUrl ? "Yes" : "No");
+                    if (cleanOCUrl == cleanOverrideUrl) {
                         qCInfo(lcAccountManager) << "Copy settings" << oCSettings->allKeys().join(", ");
                         settings = std::move(oCSettings);
                     }