Skip to content

Commit 71750f3

Browse files
committed
WIP: pass updater mirrors on relaunch
1 parent c0081f2 commit 71750f3

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct CommandLineOptions {
6363
QString ariaLogFilename;
6464
int splashMilliseconds = 3000;
6565
RelaunchCommand relaunchCommand = RelaunchCommand::NONE;
66-
QString updateUpdaterUrl;
66+
QStringList updateUpdaterUrls;
6767
QString connectUrl;
6868
};
6969

@@ -151,9 +151,9 @@ CommandLineOptions getCommandLineOptions(const QApplication& app) {
151151
} else if (command.startsWith("updateupdater")) {
152152
options.relaunchCommand = RelaunchCommand::UPDATE_UPDATER;
153153
if (optionParser.isSet(updaterUrl)) {
154-
options.updateUpdaterUrl = optionParser.value(updaterUrl);
154+
options.updateUpdaterUrls = optionParser.values(updaterUrl);
155155
} else {
156-
options.updateUpdaterUrl = "";
156+
options.updateUpdaterUrls = QStringList();
157157
}
158158
} else {
159159
argParseError("Invalid --internalcommand option: " + command);
@@ -216,7 +216,7 @@ int main(int argc, char *argv[])
216216
}
217217

218218
SplashController splashController(
219-
options.relaunchCommand, options.updateUpdaterUrl, options.connectUrl, settings);
219+
options.relaunchCommand, options.updateUpdaterUrls, options.connectUrl, settings);
220220
splashController.checkForUpdate();
221221
QmlDownloader downloader(options.ariaLogFilename, options.connectUrl, splashController, settings);
222222
QQmlApplicationEngine engine;

splashcontroller.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
#include "system.h"
2424

2525
SplashController::SplashController(
26-
RelaunchCommand command, const QString& updateUpdaterUrl,
26+
RelaunchCommand command, const QStringList& updateUpdaterUrls,
2727
const QString& connectUrl, const Settings& settings) :
28-
relaunchCommand_(command), updateUpdaterUrl_(updateUpdaterUrl),
28+
relaunchCommand_(command), updateUpdaterUrls_(updateUpdaterUrls),
2929
connectUrl_(connectUrl), settings_(settings) {}
3030

3131
// Possibly initiates an asynchronous request for the latest available versions.
@@ -37,7 +37,7 @@ void SplashController::checkForUpdate()
3737
case RelaunchCommand::UPDATE_GAME:
3838
break;
3939
case RelaunchCommand::UPDATE_UPDATER:
40-
if (!updateUpdaterUrl_.isEmpty()) {
40+
if (!updateUpdaterUrls_.isEmpty()) {
4141
return;
4242
}
4343
break;
@@ -82,8 +82,8 @@ void SplashController::onCurrentVersions(QString updaterVersion, QStringList upd
8282

8383
emit newsUrlFetched(newsUrl);
8484

85-
if (relaunchCommand_ == RelaunchCommand::UPDATE_UPDATER && updateUpdaterUrl_.isEmpty()) {
86-
updateUpdaterUrl_ = latestUpdaterUrls_.at(0);
85+
if (relaunchCommand_ == RelaunchCommand::UPDATE_UPDATER && updateUpdaterUrls_.isEmpty()) {
86+
updateUpdaterUrls_ = latestUpdaterUrls_;
8787
emit updaterUpdateNeeded();
8888
}
8989
}
@@ -126,8 +126,11 @@ void SplashController::autoLaunchOrUpdate()
126126
// fetch has not succeeded yet. Only do something at that time when the updater url is
127127
// passed by command line. When the current.json fetch has succeeded, this function is
128128
// called again if there was no url passed by command line.
129-
if (!updateUpdaterUrl_.isEmpty()) {
130-
qDebug() << "Updater update to" << updateUpdaterUrl_ << "requested as relaunch action";
129+
if (!updateUpdaterUrls_.isEmpty()) {
130+
qDebug() << "Updater update requested as relaunch action";
131+
for (auto& url : updateUpdaterUrls_) {
132+
qDebug() << "Updater update available: " << url;
133+
}
131134
// It is assumed the process is already elevated
132135
emit updaterUpdate();
133136
}
@@ -143,7 +146,12 @@ void SplashController::autoLaunchOrUpdate()
143146
// If no relaunch action, detect update needed based on versions.json
144147
if (!latestUpdaterVersion_.isEmpty() && latestUpdaterVersion_ != updaterAppVersion()) {
145148
qDebug() << "Updater update to version" << latestUpdaterVersion_ << "required";
146-
QString updaterArgs = "--splashms 1 --internalcommand updateupdater --updaterurl " + latestUpdaterUrls_.at(0);
149+
QString updaterArgs = "--splashms 1 --internalcommand updateupdater";
150+
151+
for (auto& url : latestUpdaterUrls_) {
152+
updaterArgs += " --updaterurl " + url;
153+
}
154+
147155
// Remember the URL if we are doing updater update
148156
if (!connectUrl_.isEmpty()) {
149157
updaterArgs += " -- " + connectUrl_;

splashcontroller.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class SplashController : public QObject
4848
private:
4949
// Actions from command line args
5050
RelaunchCommand relaunchCommand_;
51-
QString updateUpdaterUrl_; // If command is UPDATE_UPDATER
51+
QStringList updateUpdaterUrls_; // If command is UPDATE_UPDATER
5252
QString connectUrl_; // for pre-updater-update elevation
5353

5454
const Settings& settings_;
@@ -63,7 +63,7 @@ class SplashController : public QObject
6363

6464
public:
6565
SplashController(
66-
RelaunchCommand command, const QString& updateUpdaterUrl,
66+
RelaunchCommand command, const QStringList& updateUpdaterUrls,
6767
const QString& connectUrl, const Settings& settings);
6868
void checkForUpdate();
6969
QString gameUrl();

0 commit comments

Comments
 (0)