MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / downloadPack

Method downloadPack

launcher/modplatform/modpacksch/FTBPackInstallTask.cpp:216–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216void PackInstallTask::downloadPack()
217{
218 setStatus(tr("Downloading mods..."));
219
220 auto* jobPtr = new NetJob(tr("Mod download"), APPLICATION->network());
221 for (auto const& file : m_version.files) {
222 if (file.serverOnly || file.url.isEmpty())
223 continue;
224
225 QFileInfo file_info(file.name);
226 auto cacheName = file_info.completeBaseName() + "-" + file.sha1 + "." + file_info.suffix();
227
228 auto entry = APPLICATION->metacache()->resolveEntry("ModpacksCHPacks", cacheName);
229 entry->setStale(true);
230
231 auto relpath = FS::PathCombine("minecraft", file.path, file.name);
232 auto path = FS::PathCombine(m_stagingPath, relpath);
233
234 if (m_files_to_copy.contains(path)) {
235 qWarning() << "Ignoring" << file.url << "as a file of that path is already downloading.";
236 continue;
237 }
238
239 qDebug() << "Will download" << file.url << "to" << path;
240 m_files_to_copy[path] = entry->getFullPath();
241
242 auto dl = Net::Download::makeCached(file.url, entry);
243 if (!file.sha1.isEmpty()) {
244 auto rawSha1 = QByteArray::fromHex(file.sha1.toLatin1());
245 dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
246 }
247
248 jobPtr->addNetAction(dl);
249 }
250
251 connect(jobPtr, &NetJob::succeeded, this, &PackInstallTask::onModDownloadSucceeded);
252 connect(jobPtr, &NetJob::failed, this, &PackInstallTask::onModDownloadFailed);
253 connect(jobPtr, &NetJob::progress, this, &PackInstallTask::setProgress);
254
255 m_net_job = jobPtr;
256 jobPtr->start();
257
258 m_abortable = true;
259}
260
261void PackInstallTask::onModDownloadSucceeded()
262{

Callers

nothing calls this directly

Calls 11

PathCombineFunction · 0.85
networkMethod · 0.80
isEmptyMethod · 0.80
resolveEntryMethod · 0.80
metacacheMethod · 0.80
getFullPathMethod · 0.80
addNetActionMethod · 0.80
setStaleMethod · 0.45
containsMethod · 0.45
addValidatorMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected