aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@users.noreply.github.com>2021-06-30 17:25:50 +0200
committerGitHub <noreply@github.com>2021-06-30 17:25:50 +0200
commit417994735a4823782f0f2304695347a13eed9a1d (patch)
tree927a8e5a8d5a149cc78dbc49a07966e2c9917d2f /api
parentdc3a4cebce489b5d61081a315311ffa3d34992ef (diff)
parent2e78b64058925aca0c7a6e7013be7119b66f20d7 (diff)
downloadPrismLauncher-417994735a4823782f0f2304695347a13eed9a1d.tar.gz
PrismLauncher-417994735a4823782f0f2304695347a13eed9a1d.tar.bz2
PrismLauncher-417994735a4823782f0f2304695347a13eed9a1d.zip
Merge pull request #3914 from jamierocks/mch-check-checksums
NOISSUE Cache modpacks.ch files and check their checksums
Diffstat (limited to 'api')
-rw-r--r--api/logic/java/JavaUtils.cpp4
-rw-r--r--api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp29
-rw-r--r--api/logic/modplatform/modpacksch/FTBPackInstallTask.h2
3 files changed, 32 insertions, 3 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<QString> JavaUtils::FindJavaPaths()
QList<JavaInstallPtr> ZULU64s = this->FindJavaFromRegistryKey(
KEY_WOW64_64KEY, "SOFTWARE\\Azul Systems\\Zulu", "InstallationPath");
QList<JavaInstallPtr> ZULU32s = this->FindJavaFromRegistryKey(
- KEY_WOW64_64KEY, "SOFTWARE\\Azul Systems\\Zulu", "InstallationPath");
+ KEY_WOW64_32KEY, "SOFTWARE\\Azul Systems\\Zulu", "InstallationPath");
// BellSoft Liberica
QList<JavaInstallPtr> LIBERICA64s = this->FindJavaFromRegistryKey(
KEY_WOW64_64KEY, "SOFTWARE\\BellSoft\\Liberica", "InstallationPath");
QList<JavaInstallPtr> 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);
diff --git a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp
index ddc7fe35..6067c56a 100644
--- a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp
+++ b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp
@@ -1,10 +1,12 @@
#include "FTBPackInstallTask.h"
#include "BuildConfig.h"
+#include "Env.h"
#include "FileSystem.h"
#include "Json.h"
#include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h"
+#include "net/ChecksumValidator.h"
#include "settings/INISettingsObject.h"
namespace ModpacksCH {
@@ -93,11 +95,23 @@ 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));
+ }
jobPtr->addNetAction(dl);
}
@@ -121,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<QString, QString> filesToCopy;
+
};
}