Merge pull request #334 from flowln/right_file_2

Fix skipping file in mod version parsing
This commit is contained in:
Ezekiel Smith 2022-03-24 20:28:12 +11:00 committed by GitHub
commit f66910d054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,7 +55,8 @@ void Modrinth::loadIndexedPackVersions(Modrinth::IndexedPack & pack, QJsonArray
// Find correct file (needed in cases where one version may have multiple files) // Find correct file (needed in cases where one version may have multiple files)
// Will default to the last one if there's no primary (though I think Modrinth requires that // Will default to the last one if there's no primary (though I think Modrinth requires that
// at least one file is primary, idk) // at least one file is primary, idk)
while (i < files.count()){ // NOTE: files.count() is 1-indexed, so we need to subtract 1 to become 0-indexed
while (i < files.count() - 1){
auto parent = files[i].toObject(); auto parent = files[i].toObject();
auto fileName = Json::requireString(parent, "filename"); auto fileName = Json::requireString(parent, "filename");
@ -77,6 +78,7 @@ void Modrinth::loadIndexedPackVersions(Modrinth::IndexedPack & pack, QJsonArray
i++; i++;
} }
auto parent = files[i].toObject(); auto parent = files[i].toObject();
if(parent.contains("url")) { if(parent.contains("url")) {
file.downloadUrl = Json::requireString(parent, "url"); file.downloadUrl = Json::requireString(parent, "url");