mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-21 20:27:45 +00:00
Use new Dalamud distribution servers, improve asset updater logging
This commit is contained in:
parent
092e13e513
commit
0e909c6670
5 changed files with 60 additions and 66 deletions
|
@ -28,7 +28,7 @@ SPDX-License-Identifier: CC0-1.0
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
</entry>
|
</entry>
|
||||||
<entry name="DalamudDistribServer" type="String">
|
<entry name="DalamudDistribServer" type="String">
|
||||||
<default>goatcorp.github.io</default>
|
<default>kamori.goats.dev</default>
|
||||||
</entry>
|
</entry>
|
||||||
<entry name="SquareEnixServer" type="String">
|
<entry name="SquareEnixServer" type="String">
|
||||||
<default>ffxiv.com</default>
|
<default>ffxiv.com</default>
|
||||||
|
|
|
@ -30,9 +30,10 @@ private:
|
||||||
QCoro::Task<> installDalamud();
|
QCoro::Task<> installDalamud();
|
||||||
QCoro::Task<> installRuntime();
|
QCoro::Task<> installRuntime();
|
||||||
|
|
||||||
[[nodiscard]] QUrl dalamudVersionManifestUrl(Profile::DalamudChannel channel) const;
|
[[nodiscard]] QUrl dalamudVersionManifestUrl() const;
|
||||||
[[nodiscard]] QUrl dalamudLatestPackageUrl(Profile::DalamudChannel channel) const;
|
|
||||||
[[nodiscard]] QUrl dalamudAssetManifestUrl() const;
|
[[nodiscard]] QUrl dalamudAssetManifestUrl() const;
|
||||||
|
[[nodiscard]] QUrl dotnetRuntimePackageUrl(const QString &version) const;
|
||||||
|
[[nodiscard]] QUrl dotnetDesktopPackageUrl(const QString &version) const;
|
||||||
|
|
||||||
LauncherCore &launcher;
|
LauncherCore &launcher;
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ private:
|
||||||
|
|
||||||
int remoteDalamudAssetVersion = -1;
|
int remoteDalamudAssetVersion = -1;
|
||||||
QJsonArray remoteDalamudAssetArray;
|
QJsonArray remoteDalamudAssetArray;
|
||||||
|
QString remoteDalamudDownloadUrl;
|
||||||
|
|
||||||
Profile &m_profile;
|
Profile &m_profile;
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
};
|
};
|
||||||
Q_ENUM(WineType)
|
Q_ENUM(WineType)
|
||||||
|
|
||||||
enum class DalamudChannel { Stable, Staging, Net5 };
|
enum class DalamudChannel { Stable, Staging };
|
||||||
Q_ENUM(DalamudChannel)
|
Q_ENUM(DalamudChannel)
|
||||||
|
|
||||||
enum class DalamudInjectMethod { Entrypoint, DLLInject };
|
enum class DalamudInjectMethod { Entrypoint, DLLInject };
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
#include "assetupdater.h"
|
#include "assetupdater.h"
|
||||||
|
#include "astra_log.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
@ -15,9 +16,6 @@
|
||||||
#include <JlCompress.h>
|
#include <JlCompress.h>
|
||||||
#include <QtConcurrentRun>
|
#include <QtConcurrentRun>
|
||||||
|
|
||||||
const QString dotnetRuntimePackageURL = QStringLiteral("https://dotnetcli.azureedge.net/dotnet/Runtime/%1/dotnet-runtime-%1-win-x64.zip");
|
|
||||||
const QString dotnetDesktopPackageURL = QStringLiteral("https://dotnetcli.azureedge.net/dotnet/WindowsDesktop/%1/windowsdesktop-runtime-%1-win-x64.zip");
|
|
||||||
|
|
||||||
AssetUpdater::AssetUpdater(Profile &profile, LauncherCore &launcher, QObject *parent)
|
AssetUpdater::AssetUpdater(Profile &profile, LauncherCore &launcher, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, launcher(launcher)
|
, launcher(launcher)
|
||||||
|
@ -33,7 +31,7 @@ QCoro::Task<> AssetUpdater::update()
|
||||||
co_return;
|
co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qInfo() << "Starting asset update sequence...";
|
qInfo(ASTRA_LOG) << "Checking for asset updates...";
|
||||||
|
|
||||||
dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
dalamudDir = dataDir.absoluteFilePath(QStringLiteral("dalamud"));
|
dalamudDir = dataDir.absoluteFilePath(QStringLiteral("dalamud"));
|
||||||
|
@ -65,15 +63,15 @@ QCoro::Task<> AssetUpdater::checkRemoteDalamudAssetVersion()
|
||||||
// TODO: handle asset failure
|
// TODO: handle asset failure
|
||||||
const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
|
const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
|
||||||
|
|
||||||
remoteDalamudAssetVersion = doc.object()[QLatin1String("Version")].toInt();
|
remoteDalamudAssetVersion = doc.object()[QLatin1String("version")].toInt();
|
||||||
remoteDalamudAssetArray = doc.object()[QLatin1String("Assets")].toArray();
|
remoteDalamudAssetArray = doc.object()[QLatin1String("assets")].toArray();
|
||||||
|
|
||||||
qInfo() << "Dalamud asset remote version" << remoteDalamudAssetVersion;
|
qInfo(ASTRA_LOG) << "Dalamud asset remote version" << remoteDalamudAssetVersion;
|
||||||
qInfo() << "Dalamud asset local version" << m_profile.dalamudAssetVersion();
|
qInfo(ASTRA_LOG) << "Dalamud asset local version" << m_profile.dalamudAssetVersion();
|
||||||
|
|
||||||
// dalamud assets
|
// dalamud assets
|
||||||
if (remoteDalamudAssetVersion != m_profile.dalamudAssetVersion()) {
|
if (remoteDalamudAssetVersion != m_profile.dalamudAssetVersion()) {
|
||||||
qInfo() << "Dalamud assets out of date.";
|
qInfo(ASTRA_LOG) << "Dalamud assets out of date";
|
||||||
|
|
||||||
co_await installDalamudAssets();
|
co_await installDalamudAssets();
|
||||||
}
|
}
|
||||||
|
@ -81,7 +79,12 @@ QCoro::Task<> AssetUpdater::checkRemoteDalamudAssetVersion()
|
||||||
|
|
||||||
QCoro::Task<> AssetUpdater::checkRemoteDalamudVersion()
|
QCoro::Task<> AssetUpdater::checkRemoteDalamudVersion()
|
||||||
{
|
{
|
||||||
const QNetworkRequest request(dalamudVersionManifestUrl(m_profile.dalamudChannel()));
|
QUrl url(dalamudVersionManifestUrl());
|
||||||
|
|
||||||
|
QUrlQuery query;
|
||||||
|
query.addQueryItem(QStringLiteral("track"), m_profile.dalamudChannelName());
|
||||||
|
|
||||||
|
const QNetworkRequest request(url);
|
||||||
Utility::printRequest(QStringLiteral("GET"), request);
|
Utility::printRequest(QStringLiteral("GET"), request);
|
||||||
|
|
||||||
remoteDalamudVersion.clear();
|
remoteDalamudVersion.clear();
|
||||||
|
@ -95,34 +98,19 @@ QCoro::Task<> AssetUpdater::checkRemoteDalamudVersion()
|
||||||
co_return;
|
co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QByteArray str = reply->readAll();
|
const QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
|
||||||
|
remoteDalamudVersion = doc[QLatin1String("assemblyVersion")].toString();
|
||||||
|
remoteRuntimeVersion = doc[QLatin1String("runtimeVersion")].toString();
|
||||||
|
remoteDalamudDownloadUrl = doc[QLatin1String("downloadUrl")].toString();
|
||||||
|
|
||||||
// for some godforsaken reason, the version string comes back as raw
|
qInfo(ASTRA_LOG) << "Latest available Dalamud version:" << remoteDalamudVersion << "local:" << m_profile.dalamudVersion();
|
||||||
// bytes, ex: \xFF\xFE{\x00\"\x00""A\x00s\x00s\x00""e\x00m\x00 so we
|
qInfo(ASTRA_LOG) << "Latest available NET runtime:" << remoteRuntimeVersion;
|
||||||
// start at the first character of the json '{' and work our way up.
|
|
||||||
QString reassmbled;
|
|
||||||
for (int i = static_cast<int>(str.indexOf('{')); i < str.size(); i++) {
|
|
||||||
char t = str[i];
|
|
||||||
if (QChar(t).isPrint())
|
|
||||||
reassmbled += t;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QJsonDocument doc = QJsonDocument::fromJson(reassmbled.toUtf8());
|
|
||||||
remoteDalamudVersion = doc[QLatin1String("AssemblyVersion")].toString();
|
|
||||||
remoteRuntimeVersion = doc[QLatin1String("RuntimeVersion")].toString();
|
|
||||||
|
|
||||||
qInfo() << "Latest Dalamud version reported:" << remoteDalamudVersion << "local:" << m_profile.dalamudVersion();
|
|
||||||
qInfo() << "Latest NET runtime reported:" << remoteRuntimeVersion;
|
|
||||||
|
|
||||||
if (remoteDalamudVersion != m_profile.dalamudVersion()) {
|
if (remoteDalamudVersion != m_profile.dalamudVersion()) {
|
||||||
qInfo() << "Downloading Dalamud...";
|
|
||||||
|
|
||||||
co_await installDalamud();
|
co_await installDalamud();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_profile.runtimeVersion() != remoteRuntimeVersion) {
|
if (m_profile.runtimeVersion() != remoteRuntimeVersion) {
|
||||||
qInfo() << "Downloading Runtime...";
|
|
||||||
|
|
||||||
co_await installRuntime();
|
co_await installRuntime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,13 +122,13 @@ QCoro::Task<> AssetUpdater::installDalamudAssets()
|
||||||
QFutureSynchronizer<void> synchronizer;
|
QFutureSynchronizer<void> synchronizer;
|
||||||
|
|
||||||
for (const auto &assetObject : remoteDalamudAssetArray) {
|
for (const auto &assetObject : remoteDalamudAssetArray) {
|
||||||
const QNetworkRequest assetRequest(assetObject.toObject()[QLatin1String("Url")].toString());
|
const QNetworkRequest assetRequest(assetObject.toObject()[QLatin1String("url")].toString());
|
||||||
Utility::printRequest(QStringLiteral("GET"), assetRequest);
|
Utility::printRequest(QStringLiteral("GET"), assetRequest);
|
||||||
|
|
||||||
const auto assetReply = launcher.mgr->get(assetRequest);
|
const auto assetReply = launcher.mgr->get(assetRequest);
|
||||||
|
|
||||||
const auto future = QtFuture::connect(assetReply, &QNetworkReply::finished).then([this, assetReply, assetObject] {
|
const auto future = QtFuture::connect(assetReply, &QNetworkReply::finished).then([this, assetReply, assetObject] {
|
||||||
const QString fileName = assetObject.toObject()[QLatin1String("FileName")].toString();
|
const QString fileName = assetObject.toObject()[QLatin1String("fileName")].toString();
|
||||||
const QString dirPath = fileName.left(fileName.lastIndexOf(QLatin1Char('/')));
|
const QString dirPath = fileName.left(fileName.lastIndexOf(QLatin1Char('/')));
|
||||||
|
|
||||||
const QString path = dalamudAssetDir.absoluteFilePath(dirPath);
|
const QString path = dalamudAssetDir.absoluteFilePath(dirPath);
|
||||||
|
@ -148,7 +136,7 @@ QCoro::Task<> AssetUpdater::installDalamudAssets()
|
||||||
if (!QDir().exists(path))
|
if (!QDir().exists(path))
|
||||||
QDir().mkpath(path);
|
QDir().mkpath(path);
|
||||||
|
|
||||||
QFile file(dalamudAssetDir.absoluteFilePath(assetObject.toObject()[QLatin1String("FileName")].toString()));
|
QFile file(dalamudAssetDir.absoluteFilePath(assetObject.toObject()[QLatin1String("fileName")].toString()));
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
file.write(assetReply->readAll());
|
file.write(assetReply->readAll());
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -161,7 +149,7 @@ QCoro::Task<> AssetUpdater::installDalamudAssets()
|
||||||
synchronizer.waitForFinished();
|
synchronizer.waitForFinished();
|
||||||
});
|
});
|
||||||
|
|
||||||
qInfo() << "Finished downloading Dalamud assets.";
|
qInfo(ASTRA_LOG) << "Finished downloading Dalamud assets";
|
||||||
|
|
||||||
m_profile.setDalamudAssetVersion(remoteDalamudAssetVersion);
|
m_profile.setDalamudAssetVersion(remoteDalamudAssetVersion);
|
||||||
|
|
||||||
|
@ -175,13 +163,13 @@ QCoro::Task<> AssetUpdater::installDalamud()
|
||||||
{
|
{
|
||||||
Q_EMIT launcher.stageChanged(i18n("Updating Dalamud..."));
|
Q_EMIT launcher.stageChanged(i18n("Updating Dalamud..."));
|
||||||
|
|
||||||
const QNetworkRequest request(dalamudLatestPackageUrl(chosenChannel));
|
const QNetworkRequest request(remoteDalamudDownloadUrl);
|
||||||
Utility::printRequest(QStringLiteral("GET"), request);
|
Utility::printRequest(QStringLiteral("GET"), request);
|
||||||
|
|
||||||
const auto reply = launcher.mgr->get(request);
|
const auto reply = launcher.mgr->get(request);
|
||||||
co_await reply;
|
co_await reply;
|
||||||
|
|
||||||
qInfo() << "Dalamud finished downloading!";
|
qInfo(ASTRA_LOG) << "Finished downloading Dalamud";
|
||||||
|
|
||||||
QFile file(tempDir.path() + QStringLiteral("/latest.zip"));
|
QFile file(tempDir.path() + QStringLiteral("/latest.zip"));
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
|
@ -193,7 +181,7 @@ QCoro::Task<> AssetUpdater::installDalamud()
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
// TODO: handle failure here
|
// TODO: handle failure here
|
||||||
qInfo() << "Failed to install Dalamud!";
|
qCritical(ASTRA_LOG) << "Failed to install Dalamud!";
|
||||||
}
|
}
|
||||||
|
|
||||||
m_profile.setDalamudVersion(remoteDalamudVersion);
|
m_profile.setDalamudVersion(remoteDalamudVersion);
|
||||||
|
@ -205,13 +193,13 @@ QCoro::Task<> AssetUpdater::installRuntime()
|
||||||
|
|
||||||
// core
|
// core
|
||||||
{
|
{
|
||||||
const QNetworkRequest request(dotnetRuntimePackageURL.arg(remoteRuntimeVersion));
|
const QNetworkRequest request(dotnetRuntimePackageUrl(remoteRuntimeVersion));
|
||||||
Utility::printRequest(QStringLiteral("GET"), request);
|
Utility::printRequest(QStringLiteral("GET"), request);
|
||||||
|
|
||||||
const auto reply = launcher.mgr->get(request);
|
const auto reply = launcher.mgr->get(request);
|
||||||
co_await reply;
|
co_await reply;
|
||||||
|
|
||||||
qInfo() << "Dotnet-core finished downloading!";
|
qInfo(ASTRA_LOG) << "Finished downloading Dotnet-core";
|
||||||
|
|
||||||
QFile file(tempDir.path() + QStringLiteral("/dotnet-core.zip"));
|
QFile file(tempDir.path() + QStringLiteral("/dotnet-core.zip"));
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
|
@ -221,13 +209,13 @@ QCoro::Task<> AssetUpdater::installRuntime()
|
||||||
|
|
||||||
// desktop
|
// desktop
|
||||||
{
|
{
|
||||||
const QNetworkRequest request(dotnetDesktopPackageURL.arg(remoteRuntimeVersion));
|
const QNetworkRequest request(dotnetDesktopPackageUrl(remoteRuntimeVersion));
|
||||||
Utility::printRequest(QStringLiteral("GET"), request);
|
Utility::printRequest(QStringLiteral("GET"), request);
|
||||||
|
|
||||||
const auto reply = launcher.mgr->get(request);
|
const auto reply = launcher.mgr->get(request);
|
||||||
co_await reply;
|
co_await reply;
|
||||||
|
|
||||||
qInfo() << "Dotnet-desktop finished downloading!";
|
qInfo(ASTRA_LOG) << "Finished downloading Dotnet-desktop";
|
||||||
|
|
||||||
QFile file(tempDir.path() + QStringLiteral("/dotnet-desktop.zip"));
|
QFile file(tempDir.path() + QStringLiteral("/dotnet-desktop.zip"));
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
|
@ -239,7 +227,7 @@ QCoro::Task<> AssetUpdater::installRuntime()
|
||||||
success |= !JlCompress::extractDir(tempDir.path() + QStringLiteral("/dotnet-desktop.zip"), dalamudRuntimeDir.absolutePath()).empty();
|
success |= !JlCompress::extractDir(tempDir.path() + QStringLiteral("/dotnet-desktop.zip"), dalamudRuntimeDir.absolutePath()).empty();
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
qInfo() << "Failed to install dotnet!";
|
qCritical(ASTRA_LOG) << "Failed to install dotnet!";
|
||||||
} else {
|
} else {
|
||||||
QFile file(dalamudRuntimeDir.absoluteFilePath(QStringLiteral("runtime.ver")));
|
QFile file(dalamudRuntimeDir.absoluteFilePath(QStringLiteral("runtime.ver")));
|
||||||
file.open(QIODevice::WriteOnly | QIODevice::Text);
|
file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
|
@ -248,26 +236,12 @@ QCoro::Task<> AssetUpdater::installRuntime()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const QMap<Profile::DalamudChannel, QString> channelToDistribPrefix = {{Profile::DalamudChannel::Stable, QStringLiteral("/")},
|
QUrl AssetUpdater::dalamudVersionManifestUrl() const
|
||||||
{Profile::DalamudChannel::Staging, QStringLiteral("stg/")},
|
|
||||||
{Profile::DalamudChannel::Net5, QStringLiteral("net5/")}};
|
|
||||||
|
|
||||||
QUrl AssetUpdater::dalamudVersionManifestUrl(const Profile::DalamudChannel channel) const
|
|
||||||
{
|
{
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme(launcher.preferredProtocol());
|
url.setScheme(launcher.preferredProtocol());
|
||||||
url.setHost(launcher.dalamudDistribServer());
|
url.setHost(launcher.dalamudDistribServer());
|
||||||
url.setPath(QStringLiteral("/dalamud-distrib/%1version").arg(channelToDistribPrefix[channel]));
|
url.setPath(QStringLiteral("/Dalamud/Release/VersionInfo"));
|
||||||
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
QUrl AssetUpdater::dalamudLatestPackageUrl(Profile::DalamudChannel channel) const
|
|
||||||
{
|
|
||||||
QUrl url;
|
|
||||||
url.setScheme(launcher.preferredProtocol());
|
|
||||||
url.setHost(launcher.dalamudDistribServer());
|
|
||||||
url.setPath(QStringLiteral("/dalamud-distrib/%1latest.zip").arg(channelToDistribPrefix[channel]));
|
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +251,27 @@ QUrl AssetUpdater::dalamudAssetManifestUrl() const
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme(launcher.preferredProtocol());
|
url.setScheme(launcher.preferredProtocol());
|
||||||
url.setHost(launcher.dalamudDistribServer());
|
url.setHost(launcher.dalamudDistribServer());
|
||||||
url.setPath(QStringLiteral("/DalamudAssets/asset.json"));
|
url.setPath(QStringLiteral("/Dalamud/Asset/Meta"));
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
QUrl AssetUpdater::dotnetRuntimePackageUrl(const QString &version) const
|
||||||
|
{
|
||||||
|
QUrl url;
|
||||||
|
url.setScheme(launcher.preferredProtocol());
|
||||||
|
url.setHost(launcher.dalamudDistribServer());
|
||||||
|
url.setPath(QStringLiteral("/Dalamud/Release/Runtime/DotNet/%1").arg(version));
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
QUrl AssetUpdater::dotnetDesktopPackageUrl(const QString &version) const
|
||||||
|
{
|
||||||
|
QUrl url;
|
||||||
|
url.setScheme(launcher.preferredProtocol());
|
||||||
|
url.setHost(launcher.dalamudDistribServer());
|
||||||
|
url.setPath(QStringLiteral("/Dalamud/Release/Runtime/WindowsDesktop/%1").arg(version));
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -487,8 +487,6 @@ QString Profile::dalamudChannelName() const
|
||||||
return QStringLiteral("stable");
|
return QStringLiteral("stable");
|
||||||
case DalamudChannel::Staging:
|
case DalamudChannel::Staging:
|
||||||
return QStringLiteral("staging");
|
return QStringLiteral("staging");
|
||||||
case DalamudChannel::Net5:
|
|
||||||
return QStringLiteral("net5");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
|
|
Loading…
Add table
Reference in a new issue