| 17 | } |
| 18 | |
| 19 | void 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 | |
| 52 | bool AssetUpdateTask::canAbort() const |
| 53 | { |
nothing calls this directly
no test coverage detected