diff options
author | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-06-25 12:36:27 -0700 |
---|---|---|
committer | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-06-25 12:43:48 -0700 |
commit | df4fd7df7f98589c5dba85e4b5cdf0179a77faf5 (patch) | |
tree | b382b0375a12d91305849f5dad41f4e0b04de8df /launcher/modplatform/flame/FileResolvingTask.cpp | |
parent | c8ff812ab89044890d88779e33f3c6f86c4b8f74 (diff) | |
parent | 1bd778d0ae27b3e87b800f773d5bc35708060c19 (diff) | |
download | PrismLauncher-df4fd7df7f98589c5dba85e4b5cdf0179a77faf5.tar.gz PrismLauncher-df4fd7df7f98589c5dba85e4b5cdf0179a77faf5.tar.bz2 PrismLauncher-df4fd7df7f98589c5dba85e4b5cdf0179a77faf5.zip |
Merge remote-tracking branch 'upstream/develop' into refactor/net-split-headers-to-proxy-class
Diffstat (limited to 'launcher/modplatform/flame/FileResolvingTask.cpp')
-rw-r--r-- | launcher/modplatform/flame/FileResolvingTask.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/launcher/modplatform/flame/FileResolvingTask.cpp b/launcher/modplatform/flame/FileResolvingTask.cpp index 09f0588f..28cda162 100644 --- a/launcher/modplatform/flame/FileResolvingTask.cpp +++ b/launcher/modplatform/flame/FileResolvingTask.cpp @@ -27,15 +27,16 @@ void Flame::FileResolvingTask::executeTask() setProgress(0, 3); m_dljob.reset(new NetJob("Mod id resolver", m_network)); result.reset(new QByteArray()); - //build json data to send + // build json data to send QJsonObject object; - object["fileIds"] = QJsonArray::fromVariantList(std::accumulate(m_toProcess.files.begin(), m_toProcess.files.end(), QVariantList(), [](QVariantList& l, const File& s) { - l.push_back(s.fileId); - return l; - })); + object["fileIds"] = QJsonArray::fromVariantList( + std::accumulate(m_toProcess.files.begin(), m_toProcess.files.end(), QVariantList(), [](QVariantList& l, const File& s) { + l.push_back(s.fileId); + return l; + })); QByteArray data = Json::toText(object); - auto dl = Net::ApiUpload::makeByteArray(QUrl("https://api.curseforge.com/v1/mods/files"), result.get(), data); + auto dl = Net::ApiUpload::makeByteArray(QUrl("https://api.curseforge.com/v1/mods/files"), result, data); m_dljob->addNetAction(dl); auto step_progress = std::make_shared<TaskStepProgress>(); @@ -89,17 +90,15 @@ void Flame::FileResolvingTask::netJobFinished() auto fileid = Json::requireInteger(Json::requireObject(file)["id"]); auto& out = m_toProcess.files[fileid]; try { - out.parseFromObject(Json::requireObject(file)); + out.parseFromObject(Json::requireObject(file)); } catch (const JSONValidationError& e) { qDebug() << "Blocked mod on curseforge" << out.fileName; auto hash = out.hash; - if(!hash.isEmpty()) { + if (!hash.isEmpty()) { auto url = QString("https://api.modrinth.com/v2/version_file/%1?algorithm=sha1").arg(hash); auto output = std::make_shared<QByteArray>(); - auto dl = Net::ApiDownload::makeByteArray(QUrl(url), output.get()); - QObject::connect(dl.get(), &Net::Download::succeeded, [&out]() { - out.resolved = true; - }); + auto dl = Net::ApiDownload::makeByteArray(QUrl(url), output); + QObject::connect(dl.get(), &Net::Download::succeeded, [&out]() { out.resolved = true; }); m_checkJob->addNetAction(dl); blockedProjects.insert(&out, output); @@ -171,7 +170,7 @@ void Flame::FileResolvingTask::modrinthCheckFinished() { auto projectId = mod->projectId; auto output = std::make_shared<QByteArray>(); auto url = QString("https://api.curseforge.com/v1/mods/%1").arg(projectId); - auto dl = Net::ApiDownload::makeByteArray(url, output.get()); + auto dl = Net::ApiDownload::makeByteArray(url, output); qDebug() << "Fetching url slug for file:" << mod->fileName; QObject::connect(dl.get(), &Net::Download::succeeded, [block, index, output]() { auto mod = block->at(index); // use the shared_ptr so it is captured and only freed when we are done |