mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-10-06 06:50:16 +00:00
NOISSUE Support cf-extract file type on modpacks.ch
This makes a start on supporting CurseForge pack installation through the modpacks.ch API.
This commit is contained in:
parent
cad522fe41
commit
863cf3807e
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020-2021 Jamie Mansfield <jmansfield@cadixdev.org>
|
* Copyright 2020-2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||||
* Copyright 2020-2021 Petr Mrazek <peterix@gmail.com>
|
* Copyright 2020-2021 Petr Mrazek <peterix@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
|
#include "MMCZip.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
#include "net/ChecksumValidator.h"
|
#include "net/ChecksumValidator.h"
|
||||||
@ -122,6 +123,10 @@ void PackInstallTask::downloadPack()
|
|||||||
auto entry = APPLICATION->metacache()->resolveEntry("ModpacksCHPacks", cacheName);
|
auto entry = APPLICATION->metacache()->resolveEntry("ModpacksCHPacks", cacheName);
|
||||||
entry->setStale(true);
|
entry->setStale(true);
|
||||||
|
|
||||||
|
if (file.type == "cf-extract") {
|
||||||
|
filesToExtract[entry->getFullPath()] = file;
|
||||||
|
}
|
||||||
|
else {
|
||||||
auto relpath = FS::PathCombine("minecraft", file.path, file.name);
|
auto relpath = FS::PathCombine("minecraft", file.path, file.name);
|
||||||
auto path = FS::PathCombine(m_stagingPath, relpath);
|
auto path = FS::PathCombine(m_stagingPath, relpath);
|
||||||
|
|
||||||
@ -131,6 +136,7 @@ void PackInstallTask::downloadPack()
|
|||||||
}
|
}
|
||||||
qDebug() << "Will download" << file.url << "to" << path;
|
qDebug() << "Will download" << file.url << "to" << path;
|
||||||
filesToCopy[path] = entry->getFullPath();
|
filesToCopy[path] = entry->getFullPath();
|
||||||
|
}
|
||||||
|
|
||||||
auto dl = Net::Download::makeCached(file.url, entry);
|
auto dl = Net::Download::makeCached(file.url, entry);
|
||||||
if (!file.sha1.isEmpty()) {
|
if (!file.sha1.isEmpty()) {
|
||||||
@ -163,18 +169,38 @@ void PackInstallTask::downloadPack()
|
|||||||
|
|
||||||
void PackInstallTask::install()
|
void PackInstallTask::install()
|
||||||
{
|
{
|
||||||
|
if (!filesToCopy.isEmpty()) {
|
||||||
setStatus(tr("Copying modpack files"));
|
setStatus(tr("Copying modpack files"));
|
||||||
|
|
||||||
for (auto iter = filesToCopy.begin(); iter != filesToCopy.end(); iter++) {
|
for (auto iter = filesToCopy.begin(); iter != filesToCopy.end(); iter++) {
|
||||||
auto &to = iter.key();
|
auto& to = iter.key();
|
||||||
auto &from = iter.value();
|
auto& from = iter.value();
|
||||||
FS::copy fileCopyOperation(from, to);
|
FS::copy fileCopyOperation(from, to);
|
||||||
if(!fileCopyOperation()) {
|
if (!fileCopyOperation()) {
|
||||||
qWarning() << "Failed to copy" << from << "to" << to;
|
qWarning() << "Failed to copy" << from << "to" << to;
|
||||||
emitFailed(tr("Failed to copy files"));
|
emitFailed(tr("Failed to copy files"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!filesToExtract.isEmpty()) {
|
||||||
|
setStatus(tr("Extracting modpack files"));
|
||||||
|
|
||||||
|
for (auto iter = filesToExtract.begin(); iter != filesToExtract.end(); iter++) {
|
||||||
|
auto& filePath = iter.key();
|
||||||
|
auto& file = iter.value();
|
||||||
|
|
||||||
|
auto relpath = FS::PathCombine("minecraft", file.path);
|
||||||
|
auto path = FS::PathCombine(m_stagingPath, relpath);
|
||||||
|
|
||||||
|
if (!MMCZip::extractDir(filePath, "overrides/", path)) {
|
||||||
|
qWarning() << "Failed to extract files from" << filePath << "to" << path;
|
||||||
|
emitFailed(tr("Failed to extract files"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setStatus(tr("Installing modpack"));
|
setStatus(tr("Installing modpack"));
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020-2021 Jamie Mansfield <jmansfield@cadixdev.org>
|
* Copyright 2020-2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||||
* Copyright 2020-2021 Petr Mrazek <peterix@gmail.com>
|
* Copyright 2020-2021 Petr Mrazek <peterix@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -56,6 +56,7 @@ private:
|
|||||||
QString m_version_name;
|
QString m_version_name;
|
||||||
Version m_version;
|
Version m_version;
|
||||||
|
|
||||||
|
QMap<QString, VersionFile> filesToExtract;
|
||||||
QMap<QString, QString> filesToCopy;
|
QMap<QString, QString> filesToCopy;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user