]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Make checks for config file more concise, warn when file not readable
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 15 Dec 2022 12:27:12 +0000 (13:27 +0100)
committerClaudio Cambra <claudio.cambra@gmail.com>
Thu, 15 Dec 2022 15:58:00 +0000 (16:58 +0100)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/accountmanager.cpp

index 95ba39b6305cadbc7080232209e5e6935594b961..32cb3abc393fc2a61313c355ea2742938533ca78 100644 (file)
@@ -173,43 +173,43 @@ bool AccountManager::restoreFromLegacySettings()
 
         for (const auto &configFile : legacyLocations) {
             if (const QFileInfo configFileInfo(configFile);
-                    configFileInfo.exists()) {
+                    configFileInfo.exists() && configFileInfo.isReadable()) {
 
                 qCInfo(lcAccountManager) << "Migrate: checking old config " << configFile;
 
-                if (configFileInfo.isReadable()) {
-                    std::unique_ptr<QSettings> oCSettings(new QSettings(configFile, QSettings::IniFormat));
-                    if (oCSettings->status() != QSettings::Status::NoError) {
-                        qCInfo(lcAccountManager) << "Error reading legacy configuration file" << oCSettings->status();
+                std::unique_ptr<QSettings> oCSettings(new QSettings(configFile, QSettings::IniFormat));
+                if (oCSettings->status() != QSettings::Status::NoError) {
+                    qCInfo(lcAccountManager) << "Error reading legacy configuration file" << oCSettings->status();
+                }
+
+                // 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);
                     }
 
-                    // 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);
-                        }
-
-                        // 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) << "Copy settings" << oCSettings->allKeys().join(", ");
-                            settings = std::move(oCSettings);
-                        }
-                    } else {
+                    // 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) << "Copy settings" << oCSettings->allKeys().join(", ");
                         settings = std::move(oCSettings);
                     }
-
-                    break;
+                } else {
+                    qCInfo(lcAccountManager) << "Copy settings" << oCSettings->allKeys().join(", ");
+                    settings = std::move(oCSettings);
                 }
+
+                break;
+            } else {
+                qCInfo(lcAccountManager) << "Migrate: could not read old config " << configFile;
             }
         }
     }