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

Method executeTask

launcher/minecraft/update/AssetUpdateTask.cpp:19–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19void AssetUpdateTask::executeTask()
20{
21 setStatus(tr("Updating assets index..."));
22 auto components = m_inst->getPackProfile();
23 auto profile = components->getProfile();
24 auto assets = profile->getMinecraftAssets();
25 QUrl indexUrl = assets->url;
26 QString localPath = assets->id + ".json";
27 auto job = new NetJob(
28 tr("Asset index for %1").arg(m_inst->name()),
29 APPLICATION->network()
30 );
31
32 auto metacache = APPLICATION->metacache();
33 auto entry = metacache->resolveEntry("asset_indexes", localPath);
34 entry->setStale(true);
35 auto hexSha1 = assets->sha1.toLatin1();
36 qDebug() << "Asset index SHA1:" << hexSha1;
37 auto dl = Net::Download::makeCached(indexUrl, entry);
38 auto rawSha1 = QByteArray::fromHex(assets->sha1.toLatin1());
39 dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
40 job->addNetAction(dl);
41
42 downloadJob.reset(job);
43
44 connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::assetIndexFinished);
45 connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetIndexFailed);
46 connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
47
48 qDebug() << m_inst->name() << ": Starting asset index download";
49 downloadJob->start();
50}
51
52bool AssetUpdateTask::canAbort() const
53{

Callers

nothing calls this directly

Calls 13

getPackProfileMethod · 0.80
getProfileMethod · 0.80
getMinecraftAssetsMethod · 0.80
networkMethod · 0.80
metacacheMethod · 0.80
resolveEntryMethod · 0.80
addNetActionMethod · 0.80
nameMethod · 0.45
setStaleMethod · 0.45
addValidatorMethod · 0.45
resetMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected