feat: allow trying to use multiple hash types

This commit is contained in:
flow
2022-05-06 12:42:01 -03:00
committed by flow
parent 5c5699bba5
commit 59d628208b
5 changed files with 68 additions and 19 deletions

View File

@ -116,8 +116,14 @@ auto Modrinth::loadIndexedPackVersion(QJsonObject &obj) -> ModPlatform::IndexedV
file.downloadUrl = Json::requireString(parent, "url");
file.fileName = Json::requireString(parent, "filename");
auto hash_list = Json::requireObject(parent, "hashes");
if (hash_list.contains(ProviderCaps.hashType(ModPlatform::Provider::MODRINTH)))
file.hash = Json::requireString(hash_list, ProviderCaps.hashType(ModPlatform::Provider::MODRINTH));
auto hash_types = ProviderCaps.hashType(ModPlatform::Provider::MODRINTH);
for (auto& hash_type : hash_types) {
if (hash_list.contains(hash_type)) {
file.hash = Json::requireString(hash_list, hash_type);
file.hash_type = hash_type;
break;
}
}
return file;
}