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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
QJsonArray entries;
|
QJsonArray entries;
|
||||||
|
|
||||||
|
try {
|
||||||
if (addonIds.size() == 1)
|
if (addonIds.size() == 1)
|
||||||
entries = { doc.object() };
|
entries = { doc.object() };
|
||||||
else
|
else
|
||||||
entries = Json::requireArray(doc);
|
entries = Json::requireArray(doc);
|
||||||
|
} catch (Json::JsonException& e) {
|
||||||
|
qDebug() << e.cause();
|
||||||
|
qDebug() << doc;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto entry : entries) {
|
for (auto entry : entries) {
|
||||||
|
ModPlatform::IndexedPack pack;
|
||||||
|
|
||||||
|
try {
|
||||||
auto entry_obj = Json::requireObject(entry);
|
auto entry_obj = Json::requireObject(entry);
|
||||||
|
|
||||||
ModPlatform::IndexedPack pack;
|
|
||||||
Modrinth::loadIndexedPack(pack, entry_obj);
|
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();
|
auto hash = addonIds.find(pack.addonId.toString()).value();
|
||||||
|
|
||||||
@ -323,10 +337,6 @@ Task::Ptr EnsureMetadataTask::modrinthProjectsTask()
|
|||||||
emitFail(mod);
|
emitFail(mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Json::JsonException& e) {
|
|
||||||
qDebug() << e.cause();
|
|
||||||
qDebug() << doc;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return proj_task;
|
return proj_task;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user