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 <hello@camila.codes>
This commit is contained in:
Camila 2023-02-01 20:56:34 +01:00 committed by backportbot-nextcloud[bot]
parent 851e497455
commit 9a9bb99589
2 changed files with 18 additions and 2 deletions

View File

@ -308,6 +308,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();
@ -673,14 +686,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");
}

View File

@ -145,6 +145,9 @@ private:
QNetworkConfigurationManager _networkConfigurationManager;
QTimer _checkConnectionTimer;
QString _overrideServerUrl;
QString _overrideLocalDir;
#if defined(WITH_CRASHREPORTER)
QScopedPointer<CrashReporter::Handler> _crashHandler;
#endif