Fix: if the config did not exist, overrideserverurl had no effect.
authorCamila <hello@camila.codes>
Wed, 1 Feb 2023 19:56:34 +0000 (20:56 +0100)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 2 Feb 2023 07:55:47 +0000 (08:55 +0100)
When the client runs for the first time, setting the value was done before
the config file was created. It had no effect.

Signed-off-by: Camila <hello@camila.codes>
src/gui/application.cpp
src/gui/application.h

index ed7b15c375ff69b97738a192bbfeeb6084e7ffc0..9f8d522f5343b3a6b3791f70e7f3a4978ee688f3 100644 (file)
@@ -337,6 +337,19 @@ Application::Application(int &argc, char **argv)
     }
 
     ConfigFile cfg;
+
+    {
+        // these config values will always be empty after the first client run
+        if (!_overrideServerUrl.isEmpty()) {
+             cfg.setOverrideServerUrl(_overrideServerUrl);
+        }
+
+        if (!_overrideLocalDir.isEmpty()) {
+            cfg.setOverrideLocalDir(_overrideLocalDir);
+        }
+    }
+
+
     // The timeout is initialized with an environment variable, if not, override with the value from the config
     if (!AbstractNetworkJob::httpTimeout)
         AbstractNetworkJob::httpTimeout = cfg.timeout();
@@ -713,14 +726,14 @@ void Application::parseOptions(const QStringList &options)
                     showHint("Invalid URL passed to --overrideserverurl");
                     shouldExit = true;
                 } else {
-                    ConfigFile().setOverrideServerUrl(overrideUrl);
+                    _overrideServerUrl = overrideUrl;
                 }
             } else {
                 showHint("Invalid URL passed to --overrideserverurl");
             }
         } else if (option == QStringLiteral("--overridelocaldir")) {
             if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
-                ConfigFile().setOverrideLocalDir(it.next());
+                _overrideLocalDir = it.next();
             } else {
                 showHint("Invalid URL passed to --overridelocaldir");
             }
index 5bd412077eda40c9fd80a94cbc3472cbd51008a1..8ae193264c725d8623d67aedcda66aea5cb4dfc0 100644 (file)
@@ -145,6 +145,9 @@ private:
     QNetworkConfigurationManager _networkConfigurationManager;
     QTimer _checkConnectionTimer;
 
+    QString _overrideServerUrl;
+    QString _overrideLocalDir;
+
 #if defined(WITH_CRASHREPORTER)
     QScopedPointer<CrashReporter::Handler> _crashHandler;
 #endif