| 56 | } |
| 57 | |
| 58 | void AssetUpdateTask::assetIndexFinished() |
| 59 | { |
| 60 | AssetsIndex index; |
| 61 | qDebug() << m_inst->name() << ": Finished asset index download"; |
| 62 | |
| 63 | auto components = m_inst->getPackProfile(); |
| 64 | auto profile = components->getProfile(); |
| 65 | auto assets = profile->getMinecraftAssets(); |
| 66 | |
| 67 | QString asset_fname = "assets/indexes/" + assets->id + ".json"; |
| 68 | // FIXME: this looks like a job for a generic validator based on json schema? |
| 69 | if (!AssetsUtils::loadAssetsIndexJson(assets->id, asset_fname, index)) |
| 70 | { |
| 71 | auto metacache = APPLICATION->metacache(); |
| 72 | auto entry = metacache->resolveEntry("asset_indexes", assets->id + ".json"); |
| 73 | metacache->evictEntry(entry); |
| 74 | emitFailed(tr("Failed to read the assets index!")); |
| 75 | } |
| 76 | |
| 77 | auto job = index.getDownloadJob(); |
| 78 | if(job) |
| 79 | { |
| 80 | setStatus(tr("Getting the assets files from Mojang...")); |
| 81 | downloadJob = job; |
| 82 | connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::emitSucceeded); |
| 83 | connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed); |
| 84 | connect(downloadJob.get(), &NetJob::aborted, this, [this]{ emitFailed(tr("Aborted")); }); |
| 85 | connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress); |
| 86 | downloadJob->start(); |
| 87 | return; |
| 88 | } |
| 89 | emitSucceeded(); |
| 90 | } |
| 91 | |
| 92 | void AssetUpdateTask::assetIndexFailed(QString reason) |
| 93 | { |
nothing calls this directly
no test coverage detected