NOISSUE Cache file downloads for modpacks.ch
This commit is contained in:
parent
f51efc9109
commit
c15bd655f1
@ -1,6 +1,7 @@
|
|||||||
#include "FTBPackInstallTask.h"
|
#include "FTBPackInstallTask.h"
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
#include "BuildConfig.h"
|
||||||
|
#include "Env.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
@ -94,11 +95,19 @@ void PackInstallTask::downloadPack()
|
|||||||
for(auto file : m_version.files) {
|
for(auto file : m_version.files) {
|
||||||
if(file.serverOnly) continue;
|
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 relpath = FS::PathCombine("minecraft", file.path, file.name);
|
||||||
auto path = FS::PathCombine(m_stagingPath, relpath);
|
auto path = FS::PathCombine(m_stagingPath, relpath);
|
||||||
|
|
||||||
qDebug() << "Will download" << file.url << "to" << path;
|
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()) {
|
if (!file.sha1.isEmpty()) {
|
||||||
auto rawSha1 = QByteArray::fromHex(file.sha1.toLatin1());
|
auto rawSha1 = QByteArray::fromHex(file.sha1.toLatin1());
|
||||||
dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
|
dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
|
||||||
@ -126,6 +135,19 @@ void PackInstallTask::downloadPack()
|
|||||||
|
|
||||||
void PackInstallTask::install()
|
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"));
|
setStatus(tr("Installing modpack"));
|
||||||
|
|
||||||
auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||||
|
@ -37,6 +37,8 @@ private:
|
|||||||
QString m_version_name;
|
QString m_version_name;
|
||||||
Version m_version;
|
Version m_version;
|
||||||
|
|
||||||
|
QMap<QString, QString> filesToCopy;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user