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

Method netJobFinished

launcher/modplatform/flame/FileResolvingTask.cpp:37–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37void Flame::FileResolvingTask::netJobFinished()
38{
39 setProgress(1, 3);
40 // job to check modrinth for blocked projects
41 auto job = new NetJob("Modrinth check", m_network);
42 blockedProjects = QMap<File *,QByteArray *>();
43 QJsonDocument doc;
44
45 try {
46 doc = Json::requireDocument(*result);
47 }
48 catch (const JSONValidationError &e) {
49 qDebug() << "Flame::FileResolvingTask: Json Validation error: " << e.what();
50 emitFailed(e.what());
51 return;
52 }
53
54 auto array = Json::requireArray(doc.object()["data"]);
55 for (QJsonValueRef file : array) {
56 auto fileid = Json::requireInteger(Json::requireObject(file)["id"]);
57 auto& out = m_toProcess.files[fileid];
58 try {
59 out.parseFromObject(Json::requireObject(file));
60 } catch (const JSONValidationError& e) {
61 qDebug() << "Blocked mod on curseforge" << out.fileName;
62 auto hash = out.hash;
63 if(!hash.isEmpty()) {
64 auto url = QString("https://api.modrinth.com/v2/version_file/%1?algorithm=sha1").arg(hash);
65 auto output = new QByteArray();
66 auto dl = Net::Download::makeByteArray(QUrl(url), output);
67 QObject::connect(dl.get(), &Net::Download::succeeded, [&out]() {
68 out.resolved = true;
69 });
70
71 job->addNetAction(dl);
72 blockedProjects.insert(&out, output);
73 }
74 }
75 }
76 connect(job, &NetJob::finished, this, &Flame::FileResolvingTask::modrinthCheckFinished);
77
78 job->start();
79}
80
81void Flame::FileResolvingTask::modrinthCheckFinished() {
82 setProgress(2, 3);

Callers

nothing calls this directly

Calls 13

requireDocumentFunction · 0.85
requireArrayFunction · 0.85
requireObjectFunction · 0.85
QStringClass · 0.85
QUrlClass · 0.85
whatMethod · 0.80
objectMethod · 0.80
parseFromObjectMethod · 0.80
isEmptyMethod · 0.80
addNetActionMethod · 0.80
insertMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected