mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 04:46:08 +00:00
fix: add a picked exe the session cannot see by binding its folder (#1173)
Adding a game from a single exe outside internal storage and the game library, such as a microSD card, only showed "This location is not available in the session" and added nothing. #1153 made "Add all games in this folder" bind such a folder under /root/Games, but a picked exe still had no guest path. addExe now binds the folder the same way when the session cannot see the exe (the game it belongs to, or else the exe's own folder), then adds the game. The bind is mounted from the next session start. A folder the session already sees is not bound again, and a folder the app cannot read is still refused.
This commit is contained in:
1 parent
bc3715aad6
commit
a5c587bd71
2 files changed
+44
-4
No files matched your search
@@ -133,12 +133,49 @@ class AddedExesTest {
|
||||
assertEquals(2, AddedGames.scan(app).size)
|
||||
}
|
||||
|
||||
@Test fun anExeTheSessionCannotSeeIsNotAdded() {
|
||||
@Test fun anExeTheSessionCannotSeeBindsItsFolderAndIsAdded() {
|
||||
noGamesFolders()
|
||||
val outside = exe(File(tmp.newFolder("card"), "Hades/Hades.exe"))
|
||||
assertNull(AddedGames.guestPath(app, outside))
|
||||
val game = (AddedGames.addExe(app, outside) as AddedGames.AddResult.Added).game
|
||||
assertEquals(listOf(outside.parent to "${AddedGames.GUEST_DIR}/Hades"), SessionPrefs.gameFolderBinds(app))
|
||||
assertEquals("${AddedGames.GUEST_DIR}/Hades/Hades.exe", game.guestExe)
|
||||
assertTrue(AddedGames.addExe(app, outside) is AddedGames.AddResult.Existing)
|
||||
assertEquals(1, SessionPrefs.gameFolderBinds(app).size)
|
||||
}
|
||||
|
||||
@Test fun anotherExeOfAGameTheSessionCannotSeeBindsTheGameFolder() {
|
||||
noGamesFolders()
|
||||
val held = exe(File(tmp.newFolder("card"), "Hades/Hades.exe"))
|
||||
val pick = exe(File(held.parentFile, "x64/Hades.exe"))
|
||||
AddedExes.put(app, AddedExes.Entry(held.parent!!, held.path, picked = false))
|
||||
val switched = AddedGames.addExe(app, pick) as AddedGames.AddResult.Switched
|
||||
assertEquals(listOf(held.parent to "${AddedGames.GUEST_DIR}/Hades"), SessionPrefs.gameFolderBinds(app))
|
||||
assertEquals("${AddedGames.GUEST_DIR}/Hades/x64/Hades.exe", switched.game.guestExe)
|
||||
}
|
||||
|
||||
@Test fun aGameFolderTheSessionAlreadySeesIsNotBoundAgain() {
|
||||
noGamesFolders()
|
||||
val held = onStorage("Games2/Hades/Hades.exe")
|
||||
onStorage("Games2/Hades/x64/Hades.exe")
|
||||
AddedExes.put(app, AddedExes.Entry(held.parent!!, held.path, picked = false))
|
||||
val alias = File(tmp.root, "alias").toPath()
|
||||
java.nio.file.Files.createSymbolicLink(alias, held.parentFile!!.parentFile!!.toPath())
|
||||
assertEquals(AddedGames.AddResult.Unreachable, AddedGames.addExe(app, File(alias.toFile(), "Hades/x64/Hades.exe")))
|
||||
assertEquals(0, SessionPrefs.gameFolderBinds(app).size)
|
||||
}
|
||||
|
||||
@Test fun anExeInAFolderTheAppCannotReadIsNotAdded() {
|
||||
noGamesFolders()
|
||||
val outside = exe(File(tmp.newFolder("elsewhere"), "Game/Game.exe"))
|
||||
assertEquals(AddedGames.AddResult.Unreachable, AddedGames.addExe(app, outside))
|
||||
outside.parentFile!!.setReadable(false)
|
||||
try {
|
||||
assertEquals(AddedGames.AddResult.Unreachable, AddedGames.addExe(app, outside))
|
||||
} finally {
|
||||
outside.parentFile!!.setReadable(true)
|
||||
}
|
||||
assertEquals(0, AddedExes.list(app).size)
|
||||
assertEquals(0, AddedGames.scan(app).size)
|
||||
assertEquals(0, SessionPrefs.gameFolderBinds(app).size)
|
||||
}
|
||||
|
||||
@Test fun addingAFolderTheSessionCannotSeeBindsItAndAddsItsGames() {
|
||||
|
||||
Reference in new issue
Block a user