| 82 | } |
| 83 | |
| 84 | void Technic::SolderPackInstallTask::fileListSucceeded() |
| 85 | { |
| 86 | setStatus(tr("Downloading modpack")); |
| 87 | |
| 88 | QJsonParseError parse_error {}; |
| 89 | QJsonDocument doc = QJsonDocument::fromJson(m_response, &parse_error); |
| 90 | if (parse_error.error != QJsonParseError::NoError) { |
| 91 | qWarning() << "Error while parsing JSON response from Solder at " << parse_error.offset << " reason: " << parse_error.errorString(); |
| 92 | qWarning() << m_response; |
| 93 | return; |
| 94 | } |
| 95 | auto obj = doc.object(); |
| 96 | |
| 97 | TechnicSolder::PackBuild build; |
| 98 | try { |
| 99 | TechnicSolder::loadPackBuild(build, obj); |
| 100 | } |
| 101 | catch (const JSONValidationError& e) { |
| 102 | emitFailed(tr("Could not understand pack manifest:\n") + e.cause()); |
| 103 | m_filesNetJob.reset(); |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | if (!build.minecraft.isEmpty()) |
| 108 | m_minecraftVersion = build.minecraft; |
| 109 | |
| 110 | m_filesNetJob = new NetJob(tr("Downloading modpack"), m_network); |
| 111 | |
| 112 | int i = 0; |
| 113 | for (const auto &mod : build.mods) { |
| 114 | auto path = FS::PathCombine(m_outputDir.path(), QString("%1").arg(i)); |
| 115 | |
| 116 | auto dl = Net::Download::makeFile(mod.url, path); |
| 117 | if (!mod.md5.isEmpty()) { |
| 118 | auto rawMd5 = QByteArray::fromHex(mod.md5.toLatin1()); |
| 119 | dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Md5, rawMd5)); |
| 120 | } |
| 121 | m_filesNetJob->addNetAction(dl); |
| 122 | |
| 123 | i++; |
| 124 | } |
| 125 | |
| 126 | m_modCount = build.mods.size(); |
| 127 | |
| 128 | connect(m_filesNetJob.get(), &NetJob::succeeded, this, &Technic::SolderPackInstallTask::downloadSucceeded); |
| 129 | connect(m_filesNetJob.get(), &NetJob::progress, this, &Technic::SolderPackInstallTask::downloadProgressChanged); |
| 130 | connect(m_filesNetJob.get(), &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed); |
| 131 | connect(m_filesNetJob.get(), &NetJob::aborted, this, &Technic::SolderPackInstallTask::downloadAborted); |
| 132 | m_filesNetJob->start(); |
| 133 | } |
| 134 | |
| 135 | void Technic::SolderPackInstallTask::downloadSucceeded() |
| 136 | { |
nothing calls this directly
no test coverage detected