mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
@ -5,7 +5,7 @@
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
LibrariesTask::LibrariesTask(MinecraftInstance * inst)
|
||||
LibrariesTask::LibrariesTask(MinecraftInstance* inst)
|
||||
{
|
||||
m_inst = inst;
|
||||
}
|
||||
@ -14,7 +14,7 @@ void LibrariesTask::executeTask()
|
||||
{
|
||||
setStatus(tr("Downloading required library files..."));
|
||||
qDebug() << m_inst->name() << ": downloading libraries";
|
||||
MinecraftInstance *inst = (MinecraftInstance *)m_inst;
|
||||
MinecraftInstance* inst = (MinecraftInstance*)m_inst;
|
||||
|
||||
// Build a list of URLs that will need to be downloaded.
|
||||
auto components = inst->getPackProfile();
|
||||
@ -25,18 +25,14 @@ void LibrariesTask::executeTask()
|
||||
|
||||
auto metacache = APPLICATION->metacache();
|
||||
|
||||
auto processArtifactPool = [&](const QList<LibraryPtr> & pool, QStringList & errors, const QString & localPath)
|
||||
{
|
||||
for (auto lib : pool)
|
||||
{
|
||||
if(!lib)
|
||||
{
|
||||
auto processArtifactPool = [&](const QList<LibraryPtr>& pool, QStringList& errors, const QString& localPath) {
|
||||
for (auto lib : pool) {
|
||||
if (!lib) {
|
||||
emitFailed(tr("Null jar is specified in the metadata, aborting."));
|
||||
return false;
|
||||
}
|
||||
auto dls = lib->getDownloads(inst->runtimeContext(), metacache.get(), errors, localPath);
|
||||
for(auto dl : dls)
|
||||
{
|
||||
for (auto dl : dls) {
|
||||
downloadJob->addNetAction(dl);
|
||||
}
|
||||
}
|
||||
@ -48,8 +44,7 @@ void LibrariesTask::executeTask()
|
||||
libArtifactPool.append(profile->getLibraries());
|
||||
libArtifactPool.append(profile->getNativeLibraries());
|
||||
libArtifactPool.append(profile->getMavenFiles());
|
||||
for (auto agent : profile->getAgents())
|
||||
{
|
||||
for (auto agent : profile->getAgents()) {
|
||||
libArtifactPool.append(agent->library());
|
||||
}
|
||||
libArtifactPool.append(profile->getMainJar());
|
||||
@ -58,17 +53,18 @@ void LibrariesTask::executeTask()
|
||||
QStringList failedLocalJarMods;
|
||||
processArtifactPool(profile->getJarMods(), failedLocalJarMods, inst->jarModsDir());
|
||||
|
||||
if (!failedLocalJarMods.empty() || !failedLocalLibraries.empty())
|
||||
{
|
||||
if (!failedLocalJarMods.empty() || !failedLocalLibraries.empty()) {
|
||||
downloadJob.reset();
|
||||
QString failed_all = (failedLocalLibraries + failedLocalJarMods).join("\n");
|
||||
emitFailed(tr("Some artifacts marked as 'local' are missing their files:\n%1\n\nYou need to either add the files, or removed the packages that require them.\nYou'll have to correct this problem manually.").arg(failed_all));
|
||||
emitFailed(tr("Some artifacts marked as 'local' are missing their files:\n%1\n\nYou need to either add the files, or removed the "
|
||||
"packages that require them.\nYou'll have to correct this problem manually.")
|
||||
.arg(failed_all));
|
||||
return;
|
||||
}
|
||||
|
||||
connect(downloadJob.get(), &NetJob::succeeded, this, &LibrariesTask::emitSucceeded);
|
||||
connect(downloadJob.get(), &NetJob::failed, this, &LibrariesTask::jarlibFailed);
|
||||
connect(downloadJob.get(), &NetJob::aborted, this, [this]{ emitFailed(tr("Aborted")); });
|
||||
connect(downloadJob.get(), &NetJob::aborted, this, [this] { emitFailed(tr("Aborted")); });
|
||||
connect(downloadJob.get(), &NetJob::progress, this, &LibrariesTask::progress);
|
||||
connect(downloadJob.get(), &NetJob::stepProgress, this, &LibrariesTask::propagateStepProgress);
|
||||
|
||||
@ -87,12 +83,9 @@ void LibrariesTask::jarlibFailed(QString reason)
|
||||
|
||||
bool LibrariesTask::abort()
|
||||
{
|
||||
if(downloadJob)
|
||||
{
|
||||
if (downloadJob) {
|
||||
return downloadJob->abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
qWarning() << "Prematurely aborted LibrariesTask";
|
||||
}
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user