Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
normalize paths properly in jar matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
sargunv committed Apr 18, 2020
1 parent 817620c commit 56bcfd8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions modsman-core/src/main/kotlin/modsman/modsman.kt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ class Modsman(
@FlowPreview
suspend fun matchMods(jars: List<Path>): Flow<Result<ModEntry>> {
try {
val fingerprintToJarPath = jars.map { jarPath -> fingerprint(jarPath) to jarPath.toAbsolutePath() }.toMap()
val fingerprintToJarPath = jars.map { jarPath ->
fingerprint(jarPath) to jarPath.toAbsolutePath().normalize()
}.toMap()
val matchResult = io { curseforgeClient.fingerprintAsync(fingerprintToJarPath.keys.toList()).await() }
if (matchResult.exactMatches.isEmpty()) {
return emptyFlow()
Expand All @@ -196,14 +198,15 @@ class Modsman(
.map { addon -> addon.addonId to addon }
.toMap()

val modsPath = modlist.modsPath.toAbsolutePath().normalize()
return projectIdToAddon.entries.toFlow { (projectId, addon) ->
val file = projectIdToFile.getValue(projectId)
val jarPath = fingerprintToJarPath.getValue(file.packageFingerprint)
val mod = ModEntry(
projectId = projectId,
projectName = addon.name,
fileId = file.fileId,
fileName = modlist.modsPath.toAbsolutePath().relativize(jarPath).toString()
fileName = modsPath.relativize(jarPath).toString()
)
modlist.addOrUpdate(mod)
Result.success(mod)
Expand Down

0 comments on commit 56bcfd8

Please sign in to comment.