Permalink
Browse files

GH-2478 fix jarmods being detected as missing

  • Loading branch information...
peterix committed Nov 26, 2018
1 parent 9eb4563 commit 0ee915200b87d69ca1c27fdb756fcbf6c9913a2f
Showing with 35 additions and 24 deletions.
  1. +6 −5 api/logic/minecraft/MinecraftInstance.cpp
  2. +29 −19 api/logic/minecraft/update/LibrariesTask.cpp
@@ -169,6 +169,12 @@ QString MinecraftInstance::getLocalLibraryPath() const
return libraries_dir.absolutePath();
}
QString MinecraftInstance::jarModsDir() const
{
QDir jarmods_dir(FS::PathCombine(instanceRoot(), "jarmods/"));
return jarmods_dir.absolutePath();
}
QString MinecraftInstance::loaderModsDir() const
{
return FS::PathCombine(gameRoot(), "mods");
@@ -199,11 +205,6 @@ QString MinecraftInstance::instanceConfigFolder() const
return FS::PathCombine(gameRoot(), "config");
}
QString MinecraftInstance::jarModsDir() const
{
return FS::PathCombine(instanceRoot(), "jarmods");
}
QString MinecraftInstance::libDir() const
{
return FS::PathCombine(gameRoot(), "lib");
@@ -22,34 +22,44 @@ void LibrariesTask::executeTask()
downloadJob.reset(job);
auto metacache = ENV.metacache();
QStringList failedLocalFiles;
QList<LibraryPtr> artifactPool;
artifactPool.append(profile->getLibraries());
artifactPool.append(profile->getNativeLibraries());
artifactPool.append(profile->getJarMods());
artifactPool.append(profile->getMainJar());
for (auto lib : artifactPool)
auto processArtifactPool = [&](const QList<LibraryPtr> & pool, QStringList & errors, const QString & localPath)
{
if(!lib)
for (auto lib : pool)
{
emitFailed(tr("Null jar is specified in the metadata, aborting."));
return;
if(!lib)
{
emitFailed(tr("Null jar is specified in the metadata, aborting."));
return false;
}
auto dls = lib->getDownloads(currentSystem, metacache.get(), errors, localPath);
for(auto dl : dls)
{
downloadJob->addNetAction(dl);
}
}
auto dls = lib->getDownloads(currentSystem, metacache.get(), failedLocalFiles, inst->getLocalLibraryPath());
for(auto dl : dls)
{
downloadJob->addNetAction(dl);
}
}
return true;
};
if (!failedLocalFiles.empty())
QStringList failedLocalLibraries;
QList<LibraryPtr> libArtifactPool;
libArtifactPool.append(profile->getLibraries());
libArtifactPool.append(profile->getNativeLibraries());
libArtifactPool.append(profile->getMainJar());
processArtifactPool(libArtifactPool, failedLocalLibraries, inst->getLocalLibraryPath());
QStringList failedLocalJarMods;
QList<LibraryPtr> jarmodArtifactPool = profile->getJarMods();
processArtifactPool(libArtifactPool, failedLocalJarMods, inst->jarModsDir());
if (!failedLocalJarMods.empty() || !failedLocalLibraries.empty())
{
downloadJob.reset();
QString failed_all = failedLocalFiles.join("\n");
emitFailed(tr("Some libraries marked as 'local' are missing their jar files:\n%1\n\nYou'll have to correct this problem manually.").arg(failed_all));
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 requires 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::progress, this, &LibrariesTask::progress);

0 comments on commit 0ee9152

Please sign in to comment.