mirror of
https://github.com/packwiz/packwiz.git
synced 2025-10-18 00:04:32 +02:00
Latest version fixes: correctly order preferences (fixes #198)
Both CurseForge and Modrinth preferences were not being done in a specific order - so a file with a newer Minecraft version would not necessarily take priority over a file with a more preferred loader (e.g. Quilt over Fabric) or a file with a newer release date / CurseForge ID. Also fixed a loop variable reference in the CurseForge loop, which caused eagerly resolved (included in API response) file info to be inconsistent with the chosen version, and added filtering for duplicate values in the acceptable-game-versions/primary version list to ensure game versions are always compared properly (so the same index == same version).
This commit is contained in:
@@ -242,11 +242,16 @@ func findLatestVersion(versions []*modrinthApi.Version, gameVersions []string, u
|
||||
}
|
||||
|
||||
if compare == 0 {
|
||||
if loaderIdx < latestValidLoaderIdx { // Prefer loaders; principally Quilt over Fabric, mods over datapacks (Modrinth backend handles filtering)
|
||||
compare = 1
|
||||
} else if gameVersionIdx > bestGameVersion { // Prefer later specified game versions (main version specified last)
|
||||
compare = 1
|
||||
} else if v.DatePublished.After(*latestValidVersion.DatePublished) { // FlexVer comparison is equal or disabled, compare date instead
|
||||
// Prefer later specified game versions (main version specified last)
|
||||
compare = int32(gameVersionIdx - bestGameVersion)
|
||||
}
|
||||
if compare == 0 {
|
||||
// Prefer loaders; principally Quilt over Fabric, mods over datapacks (Modrinth backend handles filtering)
|
||||
compare = int32(latestValidLoaderIdx - loaderIdx)
|
||||
}
|
||||
if compare == 0 {
|
||||
// Other comparisons are equal, compare date instead
|
||||
if v.DatePublished.After(*latestValidVersion.DatePublished) {
|
||||
compare = 1
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user