Skip to content

Commit 432d0dc

Browse files
committed
WIP: pass updater mirrors on relaunch
1 parent 26d1ae7 commit 432d0dc

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
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: 17 additions & 10 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,10 +126,12 @@ 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+
for (auto& url : updateUpdaterUrls_) {
131+
qDebug() << "Updater update to" << url << "requested as relaunch action";
132+
}
131133
// It is assumed the process is already elevated
132-
emit updaterUpdate(updateUpdaterUrl_);
134+
emit updaterUpdate(updateUpdaterUrls_);
133135
}
134136
return;
135137

@@ -143,14 +145,19 @@ void SplashController::autoLaunchOrUpdate()
143145
// If no relaunch action, detect update needed based on versions.json
144146
if (!latestUpdaterVersion_.isEmpty() && latestUpdaterVersion_ != updaterAppVersion()) {
145147
qDebug() << "Updater update to version" << latestUpdaterVersion_ << "required";
146-
QString updaterArgs = "--splashms 1 --internalcommand updateupdater --updaterurl " + latestUpdaterUrls_.at(0);
148+
QString updaterArgs = "--splashms 1 --internalcommand updateupdater";
149+
150+
for (auto& url : latestUpdaterUrls_) {
151+
updaterArgs += " --updaterurl " + url;
152+
}
153+
147154
// Remember the URL if we are doing updater update
148155
if (!connectUrl_.isEmpty()) {
149156
updaterArgs += " -- " + connectUrl_;
150157
}
151158
switch (Sys::RelaunchElevated(updaterArgs)) {
152159
case Sys::ElevationResult::UNNEEDED:
153-
emit updaterUpdate(latestUpdaterUrls_.at(0));
160+
emit updaterUpdate(latestUpdaterUrls_);
154161
return;
155162
case Sys::ElevationResult::RELAUNCHED:
156163
QCoreApplication::quit();

splashcontroller.h

Lines changed: 3 additions & 3 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();
@@ -75,7 +75,7 @@ class SplashController : public QObject
7575
signals:
7676
void updateNeeded(bool updateNeeded);
7777
void updaterUpdateNeeded();
78-
void updaterUpdate(QString updaterUrl);
78+
void updaterUpdate(QStringList updaterUrls);
7979
void newsUrlFetched(QString newsUrl);
8080

8181
private slots:

0 commit comments

Comments
 (0)