From f51efc9109c3bddd8dd83737f5600cfcef57a6f6 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Mon, 28 Jun 2021 22:09:52 +0100 Subject: [PATCH 1/3] NOISSUE Verify file checksums for modpacks.ch --- api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp index ddc7fe35..b3c97c7b 100644 --- a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp +++ b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -5,6 +5,7 @@ #include "Json.h" #include "minecraft/MinecraftInstance.h" #include "minecraft/PackProfile.h" +#include "net/ChecksumValidator.h" #include "settings/INISettingsObject.h" namespace ModpacksCH { @@ -98,6 +99,10 @@ void PackInstallTask::downloadPack() qDebug() << "Will download" << file.url << "to" << path; auto dl = Net::Download::makeFile(file.url, path); + if (!file.sha1.isEmpty()) { + auto rawSha1 = QByteArray::fromHex(file.sha1.toLatin1()); + dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1)); + } jobPtr->addNetAction(dl); } From c15bd655f1b9c87ec2950f898a157acb64b8e474 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Mon, 28 Jun 2021 22:34:38 +0100 Subject: [PATCH 2/3] NOISSUE Cache file downloads for modpacks.ch --- .../modpacksch/FTBPackInstallTask.cpp | 24 ++++++++++++++++++- .../modpacksch/FTBPackInstallTask.h | 2 ++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp index b3c97c7b..6067c56a 100644 --- a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp +++ b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -1,6 +1,7 @@ #include "FTBPackInstallTask.h" #include "BuildConfig.h" +#include "Env.h" #include "FileSystem.h" #include "Json.h" #include "minecraft/MinecraftInstance.h" @@ -94,11 +95,19 @@ void PackInstallTask::downloadPack() for(auto file : m_version.files) { if(file.serverOnly) continue; + QFileInfo fileName(file.name); + auto cacheName = fileName.completeBaseName() + "-" + file.sha1 + "." + fileName.suffix(); + + auto entry = ENV.metacache()->resolveEntry("ModpacksCHPacks", cacheName); + entry->setStale(true); + auto relpath = FS::PathCombine("minecraft", file.path, file.name); auto path = FS::PathCombine(m_stagingPath, relpath); qDebug() << "Will download" << file.url << "to" << path; - auto dl = Net::Download::makeFile(file.url, path); + filesToCopy[entry->getFullPath()] = path; + + auto dl = Net::Download::makeCached(file.url, entry); if (!file.sha1.isEmpty()) { auto rawSha1 = QByteArray::fromHex(file.sha1.toLatin1()); dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1)); @@ -126,6 +135,19 @@ void PackInstallTask::downloadPack() void PackInstallTask::install() { + setStatus(tr("Copying modpack files")); + + for (auto iter = filesToCopy.begin(); iter != filesToCopy.end(); iter++) { + auto &from = iter.key(); + auto &to = iter.value(); + FS::copy fileCopyOperation(from, to); + if(!fileCopyOperation()) { + qWarning() << "Failed to copy" << from << "to" << to; + emitFailed(tr("Failed to copy files")); + return; + } + } + setStatus(tr("Installing modpack")); auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg"); diff --git a/api/logic/modplatform/modpacksch/FTBPackInstallTask.h b/api/logic/modplatform/modpacksch/FTBPackInstallTask.h index 4f7786fd..3b2d60de 100644 --- a/api/logic/modplatform/modpacksch/FTBPackInstallTask.h +++ b/api/logic/modplatform/modpacksch/FTBPackInstallTask.h @@ -37,6 +37,8 @@ private: QString m_version_name; Version m_version; + QMap filesToCopy; + }; } From 2e78b64058925aca0c7a6e7013be7119b66f20d7 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Wed, 30 Jun 2021 00:51:33 +0100 Subject: [PATCH 3/3] NOISSUE Fix detection for 32-bit Azul or Bellsoft Java Co-authored-by: Pedro Cunha --- api/logic/java/JavaUtils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/logic/java/JavaUtils.cpp b/api/logic/java/JavaUtils.cpp index ff6a9ac5..4b231e6a 100644 --- a/api/logic/java/JavaUtils.cpp +++ b/api/logic/java/JavaUtils.cpp @@ -273,13 +273,13 @@ QList JavaUtils::FindJavaPaths() QList ZULU64s = this->FindJavaFromRegistryKey( KEY_WOW64_64KEY, "SOFTWARE\\Azul Systems\\Zulu", "InstallationPath"); QList ZULU32s = this->FindJavaFromRegistryKey( - KEY_WOW64_64KEY, "SOFTWARE\\Azul Systems\\Zulu", "InstallationPath"); + KEY_WOW64_32KEY, "SOFTWARE\\Azul Systems\\Zulu", "InstallationPath"); // BellSoft Liberica QList LIBERICA64s = this->FindJavaFromRegistryKey( KEY_WOW64_64KEY, "SOFTWARE\\BellSoft\\Liberica", "InstallationPath"); QList LIBERICA32s = this->FindJavaFromRegistryKey( - KEY_WOW64_64KEY, "SOFTWARE\\BellSoft\\Liberica", "InstallationPath"); + KEY_WOW64_32KEY, "SOFTWARE\\BellSoft\\Liberica", "InstallationPath"); // List x64 before x86 java_candidates.append(JRE64s);