1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 19:57:45 +00:00

Error out when the boot patching server returns 404

Found this while testing out Kawari, apparently we didn't check this
until now.
This commit is contained in:
Joshua Goins 2024-06-29 15:15:20 -04:00
parent 3618c509af
commit d51ba16e5c
2 changed files with 21 additions and 13 deletions

View file

@ -30,7 +30,7 @@ private:
QCoro::Task<bool> checkLoginStatus(); QCoro::Task<bool> checkLoginStatus();
/// Check for updates to the boot components. Even though we don't use these, it's checked by later login steps. /// Check for updates to the boot components. Even though we don't use these, it's checked by later login steps.
QCoro::Task<> checkBootUpdates(); QCoro::Task<bool> checkBootUpdates();
using StoredInfo = std::pair<QString, QUrl>; using StoredInfo = std::pair<QString, QUrl>;

View file

@ -37,7 +37,9 @@ QCoro::Task<std::optional<LoginAuth>> SquareEnixLogin::login(LoginInformation *i
// There seems to be a limitation in their boot patching system. // There seems to be a limitation in their boot patching system.
// Their server can only give one patch a time, so the boot process must keep trying to patch until // Their server can only give one patch a time, so the boot process must keep trying to patch until
// there is no patches left. // there is no patches left.
co_await checkBootUpdates(); if (!co_await checkBootUpdates()) {
co_return std::nullopt;
}
} }
// Then check if we can even login. // Then check if we can even login.
@ -141,7 +143,7 @@ QCoro::Task<bool> SquareEnixLogin::checkLoginStatus()
} }
} }
QCoro::Task<> SquareEnixLogin::checkBootUpdates() QCoro::Task<bool> SquareEnixLogin::checkBootUpdates()
{ {
m_lastRunHasPatched = false; m_lastRunHasPatched = false;
@ -172,19 +174,25 @@ QCoro::Task<> SquareEnixLogin::checkBootUpdates()
const auto reply = m_launcher.mgr()->get(request); const auto reply = m_launcher.mgr()->get(request);
co_await reply; co_await reply;
const QString patchList = QString::fromUtf8(reply->readAll()); if (reply->error() == QNetworkReply::NoError) {
if (!patchList.isEmpty()) { const QString patchList = QString::fromUtf8(reply->readAll());
m_patcher = new Patcher(m_launcher, m_info->profile->gamePath() + QStringLiteral("/boot"), *m_info->profile->bootData(), this); if (!patchList.isEmpty()) {
const bool hasPatched = co_await m_patcher->patch(PatchList(patchList)); m_patcher = new Patcher(m_launcher, m_info->profile->gamePath() + QStringLiteral("/boot"), *m_info->profile->bootData(), this);
if (hasPatched) { const bool hasPatched = co_await m_patcher->patch(PatchList(patchList));
// update game version information if (hasPatched) {
m_info->profile->readGameVersion(); // update game version information
m_info->profile->readGameVersion();
}
m_patcher->deleteLater();
m_lastRunHasPatched = true;
} }
m_patcher->deleteLater(); } else {
m_lastRunHasPatched = true; qWarning(ASTRA_LOG) << "Unknown error when verifying boot files:" << reply->errorString();
Q_EMIT m_launcher.loginError(i18n("Unknown error when verifying boot files.\n\n%1", reply->errorString()));
co_return false;
} }
co_return; co_return true;
} }
QCoro::Task<std::optional<SquareEnixLogin::StoredInfo>> SquareEnixLogin::getStoredValue() QCoro::Task<std::optional<SquareEnixLogin::StoredInfo>> SquareEnixLogin::getStoredValue()