mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-26 00:06:02 +00:00
fix(library): persist explicitly selected executables in discovered folders (#2818)
fix(library): keep re-selected executables and store launchers across scans
This commit is contained in:
1 parent
46d42f9ca9
commit
58430cd393
3 files changed
+59
-3
No files matched your search
@@ -92,6 +92,38 @@ class AddedExesTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun reselectingTheCurrentExeKeepsItWhenTheRankingChanges() {
|
||||
val storage = tmp.newFolder("Ranked")
|
||||
exe(File(storage, "Example/Example.exe"))
|
||||
exe(File(storage, "Example/Other.exe"))
|
||||
SessionPrefs.setAddedGamesDirs(app, emptyList())
|
||||
SessionPrefs.setGameStorage(app, storage.path, "Card")
|
||||
val folder = File(storage, "Example")
|
||||
val current = AddedGames.scan(app).single { it.folder == folder }.exe
|
||||
val other = listOf("Example.exe", "Other.exe").map { File(folder, it) }.single { it.path != current.path }
|
||||
val existing = AddedGames.addExe(app, current)
|
||||
assertTrue(existing is AddedGames.AddResult.Existing)
|
||||
assertEquals(current.path, SessionPrefs.addedGameExe(app, folder.path))
|
||||
File(folder, "MicrosoftGame.config").writeText("<Executable Name=\"${other.name}\" />")
|
||||
assertEquals(other.path, AddedGames.rank(folder).exes.first().path)
|
||||
assertEquals(current.path, AddedGames.scan(app).single { it.folder == folder }.exe.path)
|
||||
}
|
||||
|
||||
@Test fun reselectingASteamInstallsExeThroughAnAliasStoresTheReachablePath() {
|
||||
val storage = tmp.newFolder("Aliased")
|
||||
val pick = exe(File(storage, "steamapps/common/Example/Example.exe"))
|
||||
File(storage, "steamapps/appmanifest_123.acf").writeText("\"installdir\" \"Example\"")
|
||||
SessionPrefs.setAddedGamesDirs(app, emptyList())
|
||||
SessionPrefs.setGameStorage(app, storage.path, "Card")
|
||||
val alias = File(tmp.newFolder("Links"), "Example.exe")
|
||||
java.nio.file.Files.createSymbolicLink(alias.toPath(), pick.toPath())
|
||||
assertTrue(AddedGames.addExe(app, alias) is AddedGames.AddResult.Existing)
|
||||
assertEquals(pick.path, AddedExes.list(app).single { it.folder == pick.parentFile!!.path }.exe)
|
||||
assertEquals(pick.path, SessionPrefs.addedGameExe(app, pick.parentFile!!.path))
|
||||
assertEquals(pick.path, AddedGames.scan(app).single { it.folder == pick.parentFile }.exe.path)
|
||||
AddedExes.drop(app, pick.parentFile!!.path)
|
||||
}
|
||||
|
||||
@Test fun anotherExeInTheSameGameSwitchesItsExe() {
|
||||
noGamesFolders()
|
||||
val first = onStorage("Games2/Hades/Hades.exe")
|
||||
|
||||
@@ -66,6 +66,27 @@ class AddedGamesStoreScanTest {
|
||||
assertTrue(game.guestExe.endsWith("/Tools/Editor.exe"))
|
||||
}
|
||||
|
||||
@Test fun everyStoreKeepsItsLauncherWhenItsOwnExeIsReselected() {
|
||||
for (store in listOf(Store.GOG, Store.AMAZON, Store.EPIC)) {
|
||||
val folder = install(store, "own-${store.id}", "Own ${store.label}", "Binaries/Game.exe", launcher = true)
|
||||
val own = File(folder, "Binaries/Game.exe")
|
||||
val before = AddedGames.scan(app).single { it.folder.absolutePath == folder.absolutePath }
|
||||
assertTrue(AddedGames.addExe(app, own) is AddedGames.AddResult.Existing)
|
||||
val game = AddedGames.scan(app).single { it.folder.absolutePath == folder.absolutePath }
|
||||
assertEquals(own.path, game.exe.path)
|
||||
assertTrue(game.guestExe.endsWith("/" + StoreLaunch.LAUNCHER))
|
||||
assertEquals(before.appId, game.appId)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun aDifferentPickedExeOnAnyStoreGameIsRunDirectly() {
|
||||
val folder = install(Store.GOG, "tool", "Tool GOG", "Binaries/Game.exe", launcher = true)
|
||||
val tool = File(folder, "Tools/Editor.exe").apply { parentFile!!.mkdirs(); writeText("tool") }
|
||||
AddedExes.put(app, AddedExes.Entry(folder.path, tool.path, picked = true))
|
||||
val game = AddedGames.scan(app).single { it.folder.absolutePath == folder.absolutePath }
|
||||
assertTrue(game.guestExe.endsWith("/Tools/Editor.exe"))
|
||||
}
|
||||
|
||||
@Test fun anOlderSidecarsSteamSwitchIsIgnoredEveryInstallIsListed() {
|
||||
val folder = install(Store.AMAZON, "amzn1.adg.product.x", "Yakuza 0", "Yakuza0.exe")
|
||||
val file = StoreGameSidecar.file(folder)
|
||||
|
||||
Reference in new issue
Block a user