From 23db86bdf02590dff07ef04f43c34a3133513ac6 Mon Sep 17 00:00:00 2001 From: Camila Date: Wed, 1 Feb 2023 20:56:34 +0100 Subject: [PATCH] Fix: if the config did not exist, overrideserverurl had no effect. 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 --- src/gui/application.cpp | 17 +++++++++++++++-- src/gui/application.h | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gui/application.cpp b/src/gui/application.cpp index ed7b15c37..9f8d522f5 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -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"); } diff --git a/src/gui/application.h b/src/gui/application.h index 5bd412077..8ae193264 100644 --- a/src/gui/application.h +++ b/src/gui/application.h @@ -145,6 +145,9 @@ private: QNetworkConfigurationManager _networkConfigurationManager; QTimer _checkConnectionTimer; + QString _overrideServerUrl; + QString _overrideLocalDir; + #if defined(WITH_CRASHREPORTER) QScopedPointer _crashHandler; #endif -- 2.30.2