mirror of
https://github.com/modrinth/code.git
synced 2026-08-25 00:55:25 +00:00
fix: properly select correct databack versions (#6634)
This commit is contained in:
@@ -384,6 +384,7 @@ export function getLoaderFilterTypes(contentType: string) {
|
||||
if (contentType === 'plugin') return ['plugin_loader', 'plugin_platform']
|
||||
if (contentType === 'modpack') return ['modpack_loader']
|
||||
if (contentType === 'shader') return ['shader_loader']
|
||||
if (contentType === 'datapack') return ['datapack_loader']
|
||||
return []
|
||||
}
|
||||
|
||||
@@ -454,7 +455,12 @@ export function getTargetInstallPreferences(
|
||||
|
||||
return normalizeInstallPreferences({
|
||||
gameVersions: gameVersion && shouldUseTargetRuntime ? [gameVersion] : undefined,
|
||||
loaders: loader && shouldUseTargetRuntime ? [loader] : undefined,
|
||||
loaders:
|
||||
contentType === 'datapack'
|
||||
? ['datapack']
|
||||
: loader && shouldUseTargetRuntime
|
||||
? [loader]
|
||||
: undefined,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -515,10 +521,9 @@ export function mergeInstallPreferences(
|
||||
export function getLatestMatchingInstallVersion(
|
||||
versions: readonly Labrinth.Versions.v2.Version[],
|
||||
preferences: BrowseInstallPreferences,
|
||||
contentType: string,
|
||||
) {
|
||||
return [...versions]
|
||||
.filter((version) => versionMatchesPreferences(version, preferences, contentType))
|
||||
.filter((version) => versionMatchesPreferences(version, preferences))
|
||||
.sort((a, b) => new Date(b.date_published).getTime() - new Date(a.date_published).getTime())[0]
|
||||
}
|
||||
|
||||
@@ -543,11 +548,7 @@ export async function resolveInstallPlan<TProject extends BrowseInstallProject>(
|
||||
let lastError: Error | null = null
|
||||
|
||||
for (const candidate of candidates) {
|
||||
const version = getLatestMatchingInstallVersion(
|
||||
versions,
|
||||
candidate.preferences,
|
||||
options.contentType,
|
||||
)
|
||||
const version = getLatestMatchingInstallVersion(versions, candidate.preferences)
|
||||
|
||||
if (version) {
|
||||
const fileName =
|
||||
@@ -747,13 +748,11 @@ function hasPreferences(preferences: BrowseInstallPreferences) {
|
||||
function versionMatchesPreferences(
|
||||
version: Labrinth.Versions.v2.Version,
|
||||
preferences: BrowseInstallPreferences,
|
||||
contentType: string,
|
||||
) {
|
||||
const gameVersionMatches =
|
||||
!preferences.gameVersions?.length ||
|
||||
version.game_versions.some((gameVersion) => preferences.gameVersions?.includes(gameVersion))
|
||||
if (!gameVersionMatches) return false
|
||||
if (contentType === 'datapack') return true
|
||||
if (!preferences.loaders?.length) return true
|
||||
|
||||
const compatibleLoaders = getCompatibleLoaderAliasSet(preferences.loaders)
|
||||
|
||||
@@ -47,12 +47,16 @@ export function versionMatchesCompatibilityTarget(
|
||||
return false
|
||||
}
|
||||
|
||||
const normalizedVersionLoaders = version.loaders.map(normalizeLoaderAlias)
|
||||
|
||||
if (target.projectType === 'datapack') {
|
||||
return normalizedVersionLoaders.includes('datapack')
|
||||
}
|
||||
|
||||
if (target.projectType && NON_MOD_PROJECT_TYPES.has(target.projectType)) {
|
||||
return true
|
||||
}
|
||||
|
||||
const normalizedVersionLoaders = version.loaders.map(normalizeLoaderAlias)
|
||||
|
||||
if (
|
||||
target.projectType === 'modpack' &&
|
||||
(normalizedVersionLoaders.length === 0 ||
|
||||
|
||||
Reference in New Issue
Block a user