From 8e514ada623101272bf7449aa19f06b87c580aaf Mon Sep 17 00:00:00 2001 From: MaxsTechReview Date: Mon, 16 Nov 2026 15:19:10 -0500 Subject: [PATCH] fix(library): persist explicitly selected executables in discovered folders (#2703) * fix(library): persist explicitly selected executables in discovered folders * fix(library): keep reachable executable when selecting unmapped alias --- .../droiddeck/launcher/frontend/AddedGames.kt | 7 +++-- .../launcher/frontend/AddedExesTest.kt | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt index eefe397723..e3c2d9a749 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt @@ -335,7 +335,10 @@ object AddedGames { val path = canonical(exe) val owner = ownerFolder(app, exe) if (owner != null && owner.path !in SessionPrefs.removedAddedGames(app)) { - single(app, owner.path)?.takeIf { canonical(it.exe) == path }?.let { return AddResult.Existing(it) } + single(app, owner.path)?.takeIf { canonical(it.exe) == path }?.let { + if (guestPath(app, exe) != null) AddedExes.put(app, AddedExes.Entry(owner.path, exe.path)) + return AddResult.Existing(it) + } } if (guestPath(app, exe) == null) { (owner ?: exe.parentFile)?.takeIf { guestPath(app, it) == null }?.let { bindFolder(app, it) } @@ -344,7 +347,7 @@ object AddedGames { val folder = owner ?: exe.parentFile ?: return AddResult.NotFound SessionPrefs.setAddedGameRemoved(app, folder.path, false) SessionPrefs.setAddedGameExe(app, folder.path, exe.path) - if (owner == null) AddedExes.put(app, AddedExes.Entry(folder.path, exe.path)) + AddedExes.put(app, AddedExes.Entry(folder.path, exe.path)) val game = single(app, folder.path) ?: return AddResult.NotFound AddedGamesPublisher.later(app) { com.droiddeck.launcher.stores.SteamLiveShortcuts.sync(app, listOf(game)) { true } } Log.i(TAG, "added ${game.name} from its exe") diff --git a/app/src/test/java/com/droiddeck/launcher/frontend/AddedExesTest.kt b/app/src/test/java/com/droiddeck/launcher/frontend/AddedExesTest.kt index d8626a3bb0..e0fcc5593a 100644 --- a/app/src/test/java/com/droiddeck/launcher/frontend/AddedExesTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/frontend/AddedExesTest.kt @@ -62,6 +62,36 @@ class AddedExesTest { assertEquals(1, AddedGames.scan(app).size) } + @Test fun aPickedSteamInstallSurvivesFullScansWithAndWithoutAManifest() { + for (manifestFirst in listOf(false, true)) { + val storage = tmp.newFolder("Library-$manifestFirst") + val pick = exe(File(storage, "steamapps/common/Example/Example.exe")) + val other = exe(File(storage, "steamapps/common/Other/Other.exe")) + val manifest = File(storage, "steamapps/appmanifest_123.acf") + exe(File(storage, "steamapps/common/Unselected/Unselected.exe")) + File(storage, "steamapps/appmanifest_456.acf").writeText("\"installdir\" \"Unselected\"") + SessionPrefs.setAddedGamesDirs(app, emptyList()) + SessionPrefs.setGameStorage(app, storage.path, "Card") + if (manifestFirst) manifest.writeText("\"installdir\" \"Example\"") + SessionPrefs.setAddedGameLaunch(app, pick.parentFile!!.path, "--custom") + val game = result(AddedGames.addExe(app, pick)) + assertEquals(pick.path, AddedExes.list(app).single { it.folder == game.folder.path }.exe) + assertEquals(game.appId, AddedGames.scan(app).single { it.folder == game.folder }.appId) + manifest.writeText("\"installdir\" \"Example\"") + val scanned = AddedGames.scan(app).single { it.folder == game.folder } + assertEquals(game.appId, scanned.appId) + assertEquals(pick.path, scanned.exe.path) + assertEquals("--custom", scanned.launchOptions) + assertTrue(AddedGames.scan(app).none { it.folder.name == "Unselected" }) + assertTrue(AddedGames.scan(app).any { it.exe == other }) + AddedGames.remove(app, game.folder) + assertTrue(AddedGames.scan(app).none { it.folder == game.folder }) + assertTrue(AddedGames.addExe(app, pick) is AddedGames.AddResult.Switched) + assertEquals(game.appId, AddedGames.scan(app).single { it.folder == game.folder }.appId) + AddedExes.drop(app, game.folder.path) + } + } + @Test fun anotherExeInTheSameGameSwitchesItsExe() { noGamesFolders() val first = onStorage("Games2/Hades/Hades.exe")