MCPcopy Create free account
hub / github.com/MultiMC/Launcher / executeTask

Method executeTask

launcher/minecraft/update/LibrariesTask.cpp:13–69  ·  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(currentSystem, 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 libArtifactPool.append(profile->getMainJar());
52 processArtifactPool(libArtifactPool, failedLocalLibraries, inst->getLocalLibraryPath());
53
54 QStringList failedLocalJarMods;
55 processArtifactPool(profile->getJarMods(), failedLocalJarMods, inst->jarModsDir());
56
57 if (!failedLocalJarMods.empty() || !failedLocalLibraries.empty())
58 {
59 downloadJob.reset();
60 QString failed_all = (failedLocalLibraries + failedLocalJarMods).join("\n");
61 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));
62 return;
63 }
64
65 connect(downloadJob.get(), &NetJob::succeeded, this, &LibrariesTask::emitSucceeded);
66 connect(downloadJob.get(), &NetJob::failed, this, &LibrariesTask::jarlibFailed);
67 connect(downloadJob.get(), &NetJob::progress, this, &LibrariesTask::progress);
68 downloadJob->start();
69}
70

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
getMainJarMethod · 0.80
getLocalLibraryPathMethod · 0.80
getJarModsMethod · 0.80
joinMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected