fix(ModUpdater): fail mods individually when there's errors in the JSON
Prevents a single problematic mod from invalidating all the API response. Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
c294c2d1df
commit
9407596b12
@ -289,18 +289,32 @@ Task::Ptr EnsureMetadataTask::modrinthProjectsTask()
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
QJsonArray entries;
|
||||
|
||||
try {
|
||||
if (addonIds.size() == 1)
|
||||
entries = { doc.object() };
|
||||
else
|
||||
entries = Json::requireArray(doc);
|
||||
} catch (Json::JsonException& e) {
|
||||
qDebug() << e.cause();
|
||||
qDebug() << doc;
|
||||
}
|
||||
|
||||
for (auto entry : entries) {
|
||||
ModPlatform::IndexedPack pack;
|
||||
|
||||
try {
|
||||
auto entry_obj = Json::requireObject(entry);
|
||||
|
||||
ModPlatform::IndexedPack pack;
|
||||
Modrinth::loadIndexedPack(pack, entry_obj);
|
||||
} catch (Json::JsonException& e) {
|
||||
qDebug() << e.cause();
|
||||
qDebug() << doc;
|
||||
|
||||
// Skip this entry, since it has problems
|
||||
continue;
|
||||
}
|
||||
|
||||
auto hash = addonIds.find(pack.addonId.toString()).value();
|
||||
|
||||
@ -323,10 +337,6 @@ Task::Ptr EnsureMetadataTask::modrinthProjectsTask()
|
||||
emitFail(mod);
|
||||
}
|
||||
}
|
||||
} catch (Json::JsonException& e) {
|
||||
qDebug() << e.cause();
|
||||
qDebug() << doc;
|
||||
}
|
||||
});
|
||||
|
||||
return proj_task;
|
||||
|
Loading…
Reference in New Issue
Block a user