aboutsummaryrefslogtreecommitdiff
path: root/api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp')
-rw-r--r--api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp54
1 files changed, 49 insertions, 5 deletions
diff --git a/api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp b/api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp
index 89c4dfd3..55087a27 100644
--- a/api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp
+++ b/api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp
@@ -4,6 +4,7 @@
#include <MMCZip.h>
#include <minecraft/OneSixVersionFormat.h>
#include <Version.h>
+#include <net/ChecksumValidator.h>
#include "ATLPackInstallTask.h"
#include "BuildConfig.h"
@@ -27,7 +28,11 @@ PackInstallTask::PackInstallTask(UserInteractionSupport *support, QString pack,
bool PackInstallTask::abort()
{
- return true;
+ if(abortable)
+ {
+ return jobPtr->abort();
+ }
+ return false;
}
void PackInstallTask::executeTask()
@@ -407,21 +412,29 @@ void PackInstallTask::installConfigs()
auto entry = ENV.metacache()->resolveEntry("ATLauncherPacks", path);
entry->setStale(true);
- jobPtr->addNetAction(Net::Download::makeCached(url, entry));
+ auto dl = Net::Download::makeCached(url, entry);
+ if (!m_version.configs.sha1.isEmpty()) {
+ auto rawSha1 = QByteArray::fromHex(m_version.configs.sha1.toLatin1());
+ dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
+ }
+ jobPtr->addNetAction(dl);
archivePath = entry->getFullPath();
connect(jobPtr.get(), &NetJob::succeeded, this, [&]()
{
+ abortable = false;
jobPtr.reset();
extractConfigs();
});
connect(jobPtr.get(), &NetJob::failed, [&](QString reason)
{
+ abortable = false;
jobPtr.reset();
emitFailed(reason);
});
connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total)
{
+ abortable = true;
setProgress(current, total);
});
@@ -457,16 +470,31 @@ void PackInstallTask::extractConfigs()
void PackInstallTask::downloadMods()
{
qDebug() << "PackInstallTask::installMods: " << QThread::currentThreadId();
+
+ QVector<ATLauncher::VersionMod> optionalMods;
+ for (const auto& mod : m_version.mods) {
+ if (mod.optional) {
+ optionalMods.push_back(mod);
+ }
+ }
+
+ // Select optional mods, if pack contains any
+ QVector<QString> selectedMods;
+ if (!optionalMods.isEmpty()) {
+ setStatus(tr("Selecting optional mods..."));
+ selectedMods = m_support->chooseOptionalMods(optionalMods);
+ }
+
setStatus(tr("Downloading mods..."));
jarmods.clear();
jobPtr.reset(new NetJob(tr("Mod download")));
for(const auto& mod : m_version.mods) {
// skip non-client mods
- if (!mod.client) continue;
+ if(!mod.client) continue;
- // skip optional mods for now
- if(mod.optional) continue;
+ // skip optional mods that were not selected
+ if(mod.optional && !selectedMods.contains(mod.name)) continue;
QString url;
switch(mod.download) {
@@ -493,6 +521,10 @@ void PackInstallTask::downloadMods()
modsToExtract.insert(entry->getFullPath(), mod);
auto dl = Net::Download::makeCached(url, entry);
+ if (!mod.md5.isEmpty()) {
+ auto rawMd5 = QByteArray::fromHex(mod.md5.toLatin1());
+ dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Md5, rawMd5));
+ }
jobPtr->addNetAction(dl);
}
else if(mod.type == ModType::Decomp) {
@@ -501,6 +533,10 @@ void PackInstallTask::downloadMods()
modsToDecomp.insert(entry->getFullPath(), mod);
auto dl = Net::Download::makeCached(url, entry);
+ if (!mod.md5.isEmpty()) {
+ auto rawMd5 = QByteArray::fromHex(mod.md5.toLatin1());
+ dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Md5, rawMd5));
+ }
jobPtr->addNetAction(dl);
}
else {
@@ -511,6 +547,10 @@ void PackInstallTask::downloadMods()
entry->setStale(true);
auto dl = Net::Download::makeCached(url, entry);
+ if (!mod.md5.isEmpty()) {
+ auto rawMd5 = QByteArray::fromHex(mod.md5.toLatin1());
+ dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Md5, rawMd5));
+ }
jobPtr->addNetAction(dl);
auto path = FS::PathCombine(m_stagingPath, "minecraft", relpath, mod.file);
@@ -543,11 +583,13 @@ void PackInstallTask::downloadMods()
connect(jobPtr.get(), &NetJob::succeeded, this, &PackInstallTask::onModsDownloaded);
connect(jobPtr.get(), &NetJob::failed, [&](QString reason)
{
+ abortable = false;
jobPtr.reset();
emitFailed(reason);
});
connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total)
{
+ abortable = true;
setProgress(current, total);
});
@@ -555,6 +597,8 @@ void PackInstallTask::downloadMods()
}
void PackInstallTask::onModsDownloaded() {
+ abortable = false;
+
qDebug() << "PackInstallTask::onModsDownloaded: " << QThread::currentThreadId();
jobPtr.reset();