fix(battlenet): drop the unused runtime drive and list its games under the runtime path (#3188)

* fix(battlenet): drop the unused runtime drive and list its games under the runtime path

* fix(battlenet): read product.db paths decoded and keep alias-saved folders

* fix(battlenet): keep drives for paths that climb out of the runtime

* fix(battlenet): keep a drive referenced with any separator spelling

* fix(battlenet): check decoded config values before dropping a drive
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-24 23:29:32 -05:00
1 parent 1b80b506cb
commit 19d8819137
4 files changed
+244 -5

No files matched your search

@@ -236,6 +236,21 @@ class BattleNetTest {
assertNull(BattleNet.hostFolder(context, "D:\\..\\etc"))
}
@Test fun aDriveAtAnAliasOfTheAppDataFolderListsTheGameUnderTheRuntimePath() {
val root = LinuxRuntime.rootDir(context)
val data = context.filesDir.parentFile!!
val alias = File(data.parentFile, "alias-" + data.name)
java.nio.file.Files.createSymbolicLink(alias.toPath(), data.absoluteFile.toPath())
try {
val devices = File(BattleNet.prefix(context), "pfx/dosdevices").apply { mkdirs() }
java.nio.file.Files.createSymbolicLink(File(devices, "d:").toPath(), alias.absoluteFile.toPath())
val game = File(root, "root/Games/Stores/Battle.net/StarCraft").apply { mkdirs() }
val drive = "D:\\" + data.absoluteFile.toPath().relativize(game.absoluteFile.toPath()).joinToString("\\")
assertEquals(game.path, BattleNet.hostFolder(context, drive)?.path)
} finally {
java.nio.file.Files.delete(alias.toPath())
}
}
@Test fun wowForeverIsListedBesideRetailInTheSharedWorldOfWarcraftFolder() {
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
@@ -294,6 +309,21 @@ class BattleNetTest {
assertEquals(mapOf("WoWF" to root), BattleNet.ownFolders(mapOf("WoWF" to (forever to root)), mapOf("WoWF" to "/elsewhere")))
}
@Test fun aFolderSavedThroughAnAliasOfTheAppDataFolderIsKept() {
val data = context.filesDir.parentFile!!
val root = File(context.filesDir, "World of Warcraft").apply { mkdirs() }
val foreverDir = File(root, "_forever_").apply { mkdirs() }
val forever = BattleNet.title("wow_forever")!!
val alias = File(data.parentFile, "alias-" + data.name)
java.nio.file.Files.createSymbolicLink(alias.toPath(), data.absoluteFile.toPath())
try {
val saved = File(alias, data.absoluteFile.toPath().relativize(foreverDir.absoluteFile.toPath()).toString()).path
assertEquals(mapOf("WoWF" to foreverDir), BattleNet.ownFolders(mapOf("WoWF" to (forever to root)), mapOf("WoWF" to saved)))
} finally {
java.nio.file.Files.delete(alias.toPath())
}
}
@Test fun theListedFolderIsRememberedAcrossScans() {
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
val wow = File(pfx, "drive_c/Program Files (x86)/World of Warcraft").apply { mkdirs() }