MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / executeTask

Method executeTask

launcher/minecraft/update/LibrariesTask.cpp:13–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13void LibrariesTask::executeTask()
14{
15 setStatus(tr("Getting the library files from Mojang..."));
16 qDebug() << m_inst->name() << ": downloading libraries";
17 MinecraftInstance *inst = (MinecraftInstance *)m_inst;
18
19 // Build a list of URLs that will need to be downloaded.
20 auto components = inst->getPackProfile();
21 auto profile = components->getProfile();
22
23 auto job = new NetJob(tr("Libraries for instance %1").arg(inst->name()), APPLICATION->network());
24 downloadJob.reset(job);
25
26 auto metacache = APPLICATION->metacache();
27
28 auto processArtifactPool = [&](const QList<LibraryPtr> & pool, QStringList & errors, const QString & localPath)
29 {
30 for (auto lib : pool)
31 {
32 if(!lib)
33 {
34 emitFailed(tr("Null jar is specified in the metadata, aborting."));
35 return false;
36 }
37 auto dls = lib->getDownloads(inst->runtimeContext(), metacache.get(), errors, localPath);
38 for(auto dl : dls)
39 {
40 downloadJob->addNetAction(dl);
41 }
42 }
43 return true;
44 };
45
46 QStringList failedLocalLibraries;
47 QList<LibraryPtr> libArtifactPool;
48 libArtifactPool.append(profile->getLibraries());
49 libArtifactPool.append(profile->getNativeLibraries());
50 libArtifactPool.append(profile->getMavenFiles());
51 for (auto agent : profile->getAgents())
52 {
53 libArtifactPool.append(agent->library());
54 }
55 libArtifactPool.append(profile->getMainJar());
56 processArtifactPool(libArtifactPool, failedLocalLibraries, inst->getLocalLibraryPath());
57
58 QStringList failedLocalJarMods;
59 processArtifactPool(profile->getJarMods(), failedLocalJarMods, inst->jarModsDir());
60
61 if (!failedLocalJarMods.empty() || !failedLocalLibraries.empty())
62 {
63 downloadJob.reset();
64 QString failed_all = (failedLocalLibraries + failedLocalJarMods).join("\n");
65 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));
66 return;
67 }
68
69 connect(downloadJob.get(), &NetJob::succeeded, this, &LibrariesTask::emitSucceeded);
70 connect(downloadJob.get(), &NetJob::failed, this, &LibrariesTask::jarlibFailed);

Callers

nothing calls this directly

Calls 15

getPackProfileMethod · 0.80
getProfileMethod · 0.80
networkMethod · 0.80
metacacheMethod · 0.80
getDownloadsMethod · 0.80
addNetActionMethod · 0.80
appendMethod · 0.80
libraryMethod · 0.80
getMainJarMethod · 0.80
getLocalLibraryPathMethod · 0.80
getJarModsMethod · 0.80
jarModsDirMethod · 0.80

Tested by

no test coverage detected