fix: Use primary file for mod download on Modrinth
This commit is contained in:
parent
acdb54b88e
commit
fa5fa53592
@ -51,31 +51,32 @@ void Modrinth::loadIndexedPackVersions(Modrinth::IndexedPack & pack, QJsonArray
|
||||
|
||||
auto files = Json::requireArray(obj, "files");
|
||||
int i = 0;
|
||||
while (files.count() > 1 && i < files.count()){
|
||||
//try to resolve the correct file
|
||||
|
||||
// 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
|
||||
// at least one file is primary, idk)
|
||||
while (i < files.count()){
|
||||
auto parent = files[i].toObject();
|
||||
auto fileName = Json::requireString(parent, "filename");
|
||||
//avoid grabbing "dev" files
|
||||
if(fileName.contains("javadocs",Qt::CaseInsensitive) || fileName.contains("sources",Qt::CaseInsensitive)){
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
//grab the correct mod loader
|
||||
if(fileName.contains("forge",Qt::CaseInsensitive) || fileName.contains("fabric",Qt::CaseInsensitive) ){
|
||||
|
||||
// Grab the correct mod loader
|
||||
if(hasFabric){
|
||||
if(fileName.contains("forge",Qt::CaseInsensitive)){
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
if(fileName.contains("fabric",Qt::CaseInsensitive)){
|
||||
} else if(fileName.contains("fabric", Qt::CaseInsensitive)){
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Grab the primary file, if available
|
||||
if(Json::requireBoolean(parent, "primary"))
|
||||
break;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
auto parent = files[i].toObject();
|
||||
if(parent.contains("url")) {
|
||||
file.downloadUrl = Json::requireString(parent, "url");
|
||||
|
Loading…
Reference in New Issue
Block a user