Revert "Merge pull request #9 from MultiMC/develop"

This reverts commit ccc86e4e02, reversing
changes made to 306c655ab5.
This commit is contained in:
Sebastian-byte
2021-07-13 19:44:51 -05:00
parent 5019fafeb7
commit 869a92b2a2
100 changed files with 275 additions and 4805 deletions

View File

@@ -1,12 +1,10 @@
#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 {
@@ -19,11 +17,7 @@ PackInstallTask::PackInstallTask(Modpack pack, QString version)
bool PackInstallTask::abort()
{
if(abortable)
{
return jobPtr->abort();
}
return false;
return true;
}
void PackInstallTask::executeTask()
@@ -99,41 +93,31 @@ 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;
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));
}
auto dl = Net::Download::makeFile(file.url, path);
jobPtr->addNetAction(dl);
}
connect(jobPtr.get(), &NetJob::succeeded, this, [&]()
{
abortable = false;
jobPtr.reset();
install();
});
connect(jobPtr.get(), &NetJob::failed, [&](QString reason)
{
abortable = false;
jobPtr.reset();
emitFailed(reason);
// FIXME: Temporarily ignore file download failures (matching FTB's installer),
// while FTB's data is fucked.
qWarning() << "Failed to download files for modpack: " + reason;
install();
});
connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total)
{
abortable = true;
setProgress(current, total);
});
@@ -142,19 +126,6 @@ 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");

View File

@@ -16,7 +16,6 @@ public:
explicit PackInstallTask(Modpack pack, QString version);
virtual ~PackInstallTask(){}
bool canAbort() const override { return true; }
bool abort() override;
protected:
@@ -31,8 +30,6 @@ private:
void install();
private:
bool abortable = false;
NetJobPtr jobPtr;
QByteArray response;
@@ -40,8 +37,6 @@ private:
QString m_version_name;
Version m_version;
QMap<QString, QString> filesToCopy;
};
}