diff options
author | Petr Mrázek <peterix@gmail.com> | 2019-06-30 11:03:59 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2019-06-30 11:03:59 +0200 |
commit | 63330bf1113e0da3f2733ec9d6ad98fc13ad4bb7 (patch) | |
tree | 67c5f8a80cbc74e1cd58aa965a694311cf07b8ee /api/logic/modplatform/flame/FileResolvingTask.cpp | |
parent | f74e3db804f2fb3d73cbf7ab5fbdb12ecea0f259 (diff) | |
download | MultiMC-63330bf1113e0da3f2733ec9d6ad98fc13ad4bb7.tar MultiMC-63330bf1113e0da3f2733ec9d6ad98fc13ad4bb7.tar.gz MultiMC-63330bf1113e0da3f2733ec9d6ad98fc13ad4bb7.tar.lz MultiMC-63330bf1113e0da3f2733ec9d6ad98fc13ad4bb7.tar.xz MultiMC-63330bf1113e0da3f2733ec9d6ad98fc13ad4bb7.zip |
NOISSUE connect twitch URL resolving to modpack resolving. works now.
Diffstat (limited to 'api/logic/modplatform/flame/FileResolvingTask.cpp')
-rw-r--r-- | api/logic/modplatform/flame/FileResolvingTask.cpp | 66 |
1 files changed, 6 insertions, 60 deletions
diff --git a/api/logic/modplatform/flame/FileResolvingTask.cpp b/api/logic/modplatform/flame/FileResolvingTask.cpp index 24cafcdd..295574f0 100644 --- a/api/logic/modplatform/flame/FileResolvingTask.cpp +++ b/api/logic/modplatform/flame/FileResolvingTask.cpp @@ -1,7 +1,9 @@ #include "FileResolvingTask.h" #include "Json.h" -const char * metabase = "https://cursemeta.dries007.net"; +namespace { + const char * metabase = "https://cursemeta.dries007.net"; +} Flame::FileResolvingTask::FileResolvingTask(Flame::Manifest& toProcess) : m_toProcess(toProcess) @@ -34,70 +36,14 @@ void Flame::FileResolvingTask::netJobFinished() int index = 0; for(auto & bytes: results) { + auto & out = m_toProcess.files[index]; try { - auto doc = Json::requireDocument(bytes); - auto obj = Json::requireObject(doc); - auto & out = m_toProcess.files[index]; - // result code signifies true failure. - if(obj.contains("code")) - { - qCritical() << "Resolving of" << out.projectId << out.fileId << "failed because of a negative result:"; - qCritical() << bytes; - failed = true; - continue; - } - out.fileName = Json::requireString(obj, "FileNameOnDisk"); - QString rawUrl = Json::requireString(obj, "DownloadURL"); - out.url = QUrl(rawUrl, QUrl::TolerantMode); - if(!out.url.isValid()) - { - throw JSONValidationError(QString("Invalid URL: %1").arg(rawUrl)); - } - // This is a piece of a Flame project JSON pulled out into the file metadata (here) for convenience - // It is also optional - QJsonObject projObj = Json::ensureObject(obj, "_Project", {}); - if(!projObj.isEmpty()) - { - QString strType = Json::ensureString(projObj, "PackageType", "mod").toLower(); - if(strType == "singlefile") - { - out.type = File::Type::SingleFile; - } - else if(strType == "ctoc") - { - out.type = File::Type::Ctoc; - } - else if(strType == "cmod2") - { - out.type = File::Type::Cmod2; - } - else if(strType == "mod") - { - out.type = File::Type::Mod; - } - else if(strType == "folder") - { - out.type = File::Type::Folder; - } - else if(strType == "modpack") - { - out.type = File::Type::Modpack; - } - else - { - qCritical() << "Resolving of" << out.projectId << out.fileId << "failed because of unknown file type:" << strType; - out.type = File::Type::Unknown; - failed = true; - continue; - } - out.targetFolder = Json::ensureString(projObj, "Path", "mods"); - } - out.resolved = true; + failed &= (!out.parseFromBytes(bytes)); } catch (const JSONValidationError &e) { - auto & out = m_toProcess.files[index]; + qCritical() << "Resolving of" << out.projectId << out.fileId << "failed because of a parsing error:"; qCritical() << e.cause(); qCritical() << "JSON:"; |