Skip to content

Commit

Permalink
Fix over eager jar validation breaking modrinth metadata download
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Nov 13, 2023
1 parent 564f0ec commit 94f101d
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ internal abstract class PluginDownloadServiceImpl : PluginDownloadService {

val versionRequestUrl = "$apiUrl/v2/project/$apiPlugin/version/$apiVersion"
val versionJsonPath = download(
DownloadCtx(project, apiUrl, versionRequestUrl, targetDir, jsonFile, jsonVersion, setter = { plugin[jsonVersionName] = it })
DownloadCtx(project, apiUrl, versionRequestUrl, targetDir, jsonFile, jsonVersion, setter = { plugin[jsonVersionName] = it }, requireValidJar = false)
)
val versionInfo = mapper.readValue<ModrinthVersionResponse>(versionJsonPath.toFile())
val primaryFile = versionInfo.files.find { it.primary } ?: error("Could not find primary file for $download in $versionInfo")
Expand Down Expand Up @@ -280,6 +280,10 @@ internal abstract class PluginDownloadServiceImpl : PluginDownloadService {
}

private fun requireValidJarFile(ctx: DownloadCtx, displayName: String) {
if (!ctx.requireValidJar) {
return
}

val invalidPath = ctx.targetFile.resolveSibling(ctx.targetFile.fileName.toString() + ".invalid-not-jar")

try {
Expand Down Expand Up @@ -312,7 +316,8 @@ internal abstract class PluginDownloadServiceImpl : PluginDownloadService {
val targetDir: Path,
val targetFile: Path,
val version: PluginVersion,
val setter: (PluginVersion) -> Unit
val setter: (PluginVersion) -> Unit,
val requireValidJar: Boolean = true,
)
}

Expand Down

0 comments on commit 94f101d

Please sign in to comment.