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

Method fileListSucceeded

launcher/modplatform/technic/SolderPackInstallTask.cpp:84–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84void 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
135void Technic::SolderPackInstallTask::downloadSucceeded()
136{

Callers

nothing calls this directly

Calls 14

fromJsonFunction · 0.85
loadPackBuildFunction · 0.85
PathCombineFunction · 0.85
QStringClass · 0.85
objectMethod · 0.80
causeMethod · 0.80
isEmptyMethod · 0.80
pathMethod · 0.80
addNetActionMethod · 0.80
resetMethod · 0.45
addValidatorMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected