mirror of
https://github.com/modrinth/code.git
synced 2026-08-30 19:46:33 +00:00
fix: properly select correct databack versions (#6634)
This commit is contained in:
@@ -680,7 +680,6 @@ async function chooseInstanceInstallVersion(
|
|||||||
const selectedVersion = getLatestMatchingInstallVersion(
|
const selectedVersion = getLatestMatchingInstallVersion(
|
||||||
await getInstallProjectVersions(project.project_id),
|
await getInstallProjectVersions(project.project_id),
|
||||||
selectedPreferences,
|
selectedPreferences,
|
||||||
projectTypeValue,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!selectedVersion) {
|
if (!selectedVersion) {
|
||||||
|
|||||||
@@ -384,6 +384,7 @@ export function getLoaderFilterTypes(contentType: string) {
|
|||||||
if (contentType === 'plugin') return ['plugin_loader', 'plugin_platform']
|
if (contentType === 'plugin') return ['plugin_loader', 'plugin_platform']
|
||||||
if (contentType === 'modpack') return ['modpack_loader']
|
if (contentType === 'modpack') return ['modpack_loader']
|
||||||
if (contentType === 'shader') return ['shader_loader']
|
if (contentType === 'shader') return ['shader_loader']
|
||||||
|
if (contentType === 'datapack') return ['datapack_loader']
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,7 +455,12 @@ export function getTargetInstallPreferences(
|
|||||||
|
|
||||||
return normalizeInstallPreferences({
|
return normalizeInstallPreferences({
|
||||||
gameVersions: gameVersion && shouldUseTargetRuntime ? [gameVersion] : undefined,
|
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(
|
export function getLatestMatchingInstallVersion(
|
||||||
versions: readonly Labrinth.Versions.v2.Version[],
|
versions: readonly Labrinth.Versions.v2.Version[],
|
||||||
preferences: BrowseInstallPreferences,
|
preferences: BrowseInstallPreferences,
|
||||||
contentType: string,
|
|
||||||
) {
|
) {
|
||||||
return [...versions]
|
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]
|
.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
|
let lastError: Error | null = null
|
||||||
|
|
||||||
for (const candidate of candidates) {
|
for (const candidate of candidates) {
|
||||||
const version = getLatestMatchingInstallVersion(
|
const version = getLatestMatchingInstallVersion(versions, candidate.preferences)
|
||||||
versions,
|
|
||||||
candidate.preferences,
|
|
||||||
options.contentType,
|
|
||||||
)
|
|
||||||
|
|
||||||
if (version) {
|
if (version) {
|
||||||
const fileName =
|
const fileName =
|
||||||
@@ -747,13 +748,11 @@ function hasPreferences(preferences: BrowseInstallPreferences) {
|
|||||||
function versionMatchesPreferences(
|
function versionMatchesPreferences(
|
||||||
version: Labrinth.Versions.v2.Version,
|
version: Labrinth.Versions.v2.Version,
|
||||||
preferences: BrowseInstallPreferences,
|
preferences: BrowseInstallPreferences,
|
||||||
contentType: string,
|
|
||||||
) {
|
) {
|
||||||
const gameVersionMatches =
|
const gameVersionMatches =
|
||||||
!preferences.gameVersions?.length ||
|
!preferences.gameVersions?.length ||
|
||||||
version.game_versions.some((gameVersion) => preferences.gameVersions?.includes(gameVersion))
|
version.game_versions.some((gameVersion) => preferences.gameVersions?.includes(gameVersion))
|
||||||
if (!gameVersionMatches) return false
|
if (!gameVersionMatches) return false
|
||||||
if (contentType === 'datapack') return true
|
|
||||||
if (!preferences.loaders?.length) return true
|
if (!preferences.loaders?.length) return true
|
||||||
|
|
||||||
const compatibleLoaders = getCompatibleLoaderAliasSet(preferences.loaders)
|
const compatibleLoaders = getCompatibleLoaderAliasSet(preferences.loaders)
|
||||||
|
|||||||
@@ -47,12 +47,16 @@ export function versionMatchesCompatibilityTarget(
|
|||||||
return false
|
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)) {
|
if (target.projectType && NON_MOD_PROJECT_TYPES.has(target.projectType)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalizedVersionLoaders = version.loaders.map(normalizeLoaderAlias)
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
target.projectType === 'modpack' &&
|
target.projectType === 'modpack' &&
|
||||||
(normalizedVersionLoaders.length === 0 ||
|
(normalizedVersionLoaders.length === 0 ||
|
||||||
|
|||||||
Reference in New Issue
Block a user