fix(library): added-games selection edge cases from #2818 review (#3177)

fix(library): saved exes skip store games that are updating
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-24 19:26:44 -05:00
1 parent c0d14f9632
commit 906e66e3cf
2 files changed
+31 -3

No files matched your search

@@ -239,6 +239,7 @@ object AddedGames {
for (entry in AddedExes.list(context)) { for (entry in AddedExes.list(context)) {
val folder = File(entry.folder) val folder = File(entry.folder)
if (folder.path in removed || !folder.isDirectory) continue if (folder.path in removed || !folder.isDirectory) continue
if (StoreGameSidecar.read(folder)?.isInstalled == false) continue
scanGame(context, folder, out, single = entry, reuse = true) scanGame(context, folder, out, single = entry, reuse = true)
} }
for (folder in libraryDepotInstalls(context)) if (folder.path !in removed) scanGame(context, folder, out, reuse = true) for (folder in libraryDepotInstalls(context)) if (folder.path !in removed) scanGame(context, folder, out, reuse = true)
@@ -337,9 +338,10 @@ object AddedGames {
val owner = ownerFolder(app, exe) val owner = ownerFolder(app, exe)
if (owner != null && owner.path !in SessionPrefs.removedAddedGames(app)) { if (owner != null && owner.path !in SessionPrefs.removedAddedGames(app)) {
single(app, owner.path)?.takeIf { canonical(it.exe) == path }?.let { single(app, owner.path)?.takeIf { canonical(it.exe) == path }?.let {
if (guestPath(app, it.exe) != null) { val keep = listOf(it.exe, exe).firstOrNull { f -> guestPath(app, f) != null }
SessionPrefs.setAddedGameExe(app, owner.path, it.exe.path) if (keep != null) {
AddedExes.put(app, AddedExes.Entry(owner.path, it.exe.path)) SessionPrefs.setAddedGameExe(app, owner.path, keep.path)
AddedExes.put(app, AddedExes.Entry(owner.path, keep.path))
} }
return AddResult.Existing(it) return AddResult.Existing(it)
} }
@@ -137,4 +137,30 @@ class AddedGamesStoreScanTest {
val game = AddedGames.scan(app).single { it.folder.absolutePath == folder.absolutePath } val game = AddedGames.scan(app).single { it.folder.absolutePath == folder.absolutePath }
assertEquals("/root/Games/Stores/GOG/Witcher Game", game.guestDir) assertEquals("/root/Games/Stores/GOG/Witcher Game", game.guestDir)
} }
@Test fun aStoreGameThatIsUpdatingIsNotListedThroughItsSavedExe() {
val folder = install(Store.GOG, "upd", "Updating GOG", "Binaries/Game.exe", launcher = true)
val own = File(folder, "Binaries/Game.exe")
assertTrue(AddedGames.addExe(app, own) is AddedGames.AddResult.Existing)
assertTrue(AddedGames.scan(app).any { it.folder.absolutePath == folder.absolutePath })
StoreGameSidecar.read(folder)!!.copy(state = StoreGameSidecar.STATE_UPDATING).write(folder)
assertTrue(AddedGames.scan(app).none { it.folder.absolutePath == folder.absolutePath })
}
@Test fun reselectingTheMappedExeReplacesAnUnmappedAliasOfIt() {
val folder = install(Store.EPIC, "alias", "Alias Epic", "Binaries/Game.exe", launcher = true)
val own = File(folder, "Binaries/Game.exe")
val alias = File(java.nio.file.Files.createTempDirectory("alias").toFile(), "bin")
try {
java.nio.file.Files.createSymbolicLink(alias.toPath(), File(folder, "Binaries").toPath())
} catch (e: Exception) {
org.junit.Assume.assumeNoException(e)
}
val aliased = File(alias, "Game.exe")
assertNull(AddedGames.guestPath(app, aliased))
SessionPrefs.setAddedGameExe(app, folder.path, aliased.path)
assertTrue(AddedGames.addExe(app, own) is AddedGames.AddResult.Existing)
assertEquals(own.path, SessionPrefs.addedGameExe(app, folder.path))
assertEquals(own.path, AddedExes.list(app).single { it.folder == folder.path }.exe)
}
} }