mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 07:46:01 +00:00
fix(library): saved exes skip store games that are updating
This commit is contained in:
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)) {
|
||||
val folder = File(entry.folder)
|
||||
if (folder.path in removed || !folder.isDirectory) continue
|
||||
if (StoreGameSidecar.read(folder)?.isInstalled == false) continue
|
||||
scanGame(context, folder, out, single = entry, 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)
|
||||
if (owner != null && owner.path !in SessionPrefs.removedAddedGames(app)) {
|
||||
single(app, owner.path)?.takeIf { canonical(it.exe) == path }?.let {
|
||||
if (guestPath(app, it.exe) != null) {
|
||||
SessionPrefs.setAddedGameExe(app, owner.path, it.exe.path)
|
||||
AddedExes.put(app, AddedExes.Entry(owner.path, it.exe.path))
|
||||
val keep = listOf(it.exe, exe).firstOrNull { f -> guestPath(app, f) != null }
|
||||
if (keep != null) {
|
||||
SessionPrefs.setAddedGameExe(app, owner.path, keep.path)
|
||||
AddedExes.put(app, AddedExes.Entry(owner.path, keep.path))
|
||||
}
|
||||
return AddResult.Existing(it)
|
||||
}
|
||||
|
||||
@@ -137,4 +137,30 @@ class AddedGamesStoreScanTest {
|
||||
val game = AddedGames.scan(app).single { it.folder.absolutePath == folder.absolutePath }
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user