mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 03:37:47 +00:00
Bump libphysis, and check for disk space before updating the game
This fixes a really easy situation to run into, updating the game without the space required. Now it should warn you before continuing into a terrible situation.
This commit is contained in:
parent
0775a463e8
commit
0ff1dbd4e5
4 changed files with 28 additions and 1 deletions
2
external/libphysis
vendored
2
external/libphysis
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 1862f3a81f93178f55bda4ee7f88f3476f7f0062
|
Subproject commit 8d68aeed9a8fc2d04ad258ee94e44001001f3b6e
|
|
@ -64,6 +64,7 @@ private:
|
||||||
BootData *m_bootData = nullptr;
|
BootData *m_bootData = nullptr;
|
||||||
GameData *m_gameData = nullptr;
|
GameData *m_gameData = nullptr;
|
||||||
QStorageInfo m_patchesDirStorageInfo;
|
QStorageInfo m_patchesDirStorageInfo;
|
||||||
|
QStorageInfo m_baseDirStorageInfo;
|
||||||
|
|
||||||
int m_remainingPatches = -1;
|
int m_remainingPatches = -1;
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ QCoro::Task<bool> Patcher::patch(const physis_PatchList &patchList)
|
||||||
co_return false;
|
co_return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First, let's check if we have enough space to even download the patches
|
||||||
const qint64 neededSpace = patchList.patch_length - m_patchesDirStorageInfo.bytesAvailable();
|
const qint64 neededSpace = patchList.patch_length - m_patchesDirStorageInfo.bytesAvailable();
|
||||||
if (neededSpace > 0) {
|
if (neededSpace > 0) {
|
||||||
KFormat format;
|
KFormat format;
|
||||||
|
@ -63,6 +64,27 @@ QCoro::Task<bool> Patcher::patch(const physis_PatchList &patchList)
|
||||||
co_return false;
|
co_return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we do, we want to make sure we have enough space for all of the repositories we download
|
||||||
|
QMap<QString, int64_t> repositorySizes;
|
||||||
|
for (int i = 0; i < patchList.num_entries; i++) {
|
||||||
|
// Record the largest byte size for the repository
|
||||||
|
const auto &patch = patchList.entries[i];
|
||||||
|
const auto &key = Utility::repositoryFromPatchUrl(QLatin1String(patch.url));
|
||||||
|
repositorySizes[key] = std::max(patch.size_on_disk, repositorySizes.value(Utility::repositoryFromPatchUrl(QLatin1String(patch.url)), 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t requiredInstallSize = 0;
|
||||||
|
for (const auto &[_, value] : repositorySizes.asKeyValueRange()) {
|
||||||
|
requiredInstallSize += value;
|
||||||
|
}
|
||||||
|
const qint64 neededInstallSpace = requiredInstallSize - m_baseDirStorageInfo.bytesAvailable();
|
||||||
|
if (neededInstallSpace > 0) {
|
||||||
|
KFormat format;
|
||||||
|
QString neededSpaceStr = format.formatByteSize(neededInstallSpace);
|
||||||
|
Q_EMIT m_launcher.miscError(i18n("There is not enough space available on disk to update the game. You need %1 of free space.", neededSpaceStr));
|
||||||
|
co_return false;
|
||||||
|
}
|
||||||
|
|
||||||
Q_EMIT m_launcher.stageIndeterminate();
|
Q_EMIT m_launcher.stageIndeterminate();
|
||||||
Q_EMIT m_launcher.stageChanged(i18n("Updating %1", getBaseString()));
|
Q_EMIT m_launcher.stageChanged(i18n("Updating %1", getBaseString()));
|
||||||
|
|
||||||
|
@ -259,6 +281,8 @@ void Patcher::setupDirectories()
|
||||||
|
|
||||||
m_patchesDir.setPath(dataDir.absoluteFilePath(QStringLiteral("patch")));
|
m_patchesDir.setPath(dataDir.absoluteFilePath(QStringLiteral("patch")));
|
||||||
m_patchesDirStorageInfo = QStorageInfo(m_patchesDir);
|
m_patchesDirStorageInfo = QStorageInfo(m_patchesDir);
|
||||||
|
|
||||||
|
m_baseDirStorageInfo = QStorageInfo(m_baseDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Patcher::getBaseString() const
|
QString Patcher::getBaseString() const
|
||||||
|
|
|
@ -380,6 +380,8 @@ QCoro::Task<bool> SquareEnixLogin::registerSession()
|
||||||
const QString body = QString::fromUtf8(reply->readAll());
|
const QString body = QString::fromUtf8(reply->readAll());
|
||||||
|
|
||||||
if (!body.isEmpty()) {
|
if (!body.isEmpty()) {
|
||||||
|
qDebug(ASTRA_LOG) << "Game patch list:" << body;
|
||||||
|
|
||||||
m_patcher = new Patcher(m_launcher, m_info->profile->gamePath() + QStringLiteral("/game"), *m_info->profile->gameData(), this);
|
m_patcher = new Patcher(m_launcher, m_info->profile->gamePath() + QStringLiteral("/game"), *m_info->profile->gameData(), this);
|
||||||
std::string bodyStd = body.toStdString();
|
std::string bodyStd = body.toStdString();
|
||||||
const bool hasPatched = co_await m_patcher->patch(physis_parse_patchlist(PatchListType::Game, bodyStd.c_str()));
|
const bool hasPatched = co_await m_patcher->patch(physis_parse_patchlist(PatchListType::Game, bodyStd.c_str()));
|
||||||
|
|
Loading…
Add table
Reference in a new issue