mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
fix(steam): offer a Games folder as a Steam library when it is not already one (#2432)
* fix(steam): offer a Games folder as a Steam library when it is not already one * test(steam): cover discovery with chosen storage * fix(steam): compare Games folders and Steam libraries by the same storage path The Games-folder overlap check used the raw canonical path, so a library saved under the raw card mount and the same folder under /storage were treated as different. Reuse the library canonicalisation.
This commit is contained in:
1 parent
c177b1eed1
commit
3230ccdc73
3 files changed
+38
-8
No files matched your search
@@ -65,6 +65,26 @@ class SteamLibrariesTest {
|
||||
assertTrue(SteamLibraries.add(app, nested.path) is SteamLibraries.AddResult.Refused)
|
||||
}
|
||||
|
||||
@Test fun aGamesFolderIsOfferedWholeUnlessItIsAlreadyALibrary() {
|
||||
val games = "/storage/card/GameNative"
|
||||
assertTrue(SteamLibraries.offered(emptyList(), listOf(games), games))
|
||||
assertFalse(SteamLibraries.offered(emptyList(), listOf(games), "$games/Steam"))
|
||||
assertFalse(SteamLibraries.offered(emptyList(), listOf(games), "/storage/card"))
|
||||
assertFalse(SteamLibraries.offered(listOf(games), listOf(games), games))
|
||||
assertTrue(SteamLibraries.offered(listOf("/storage/card/Other"), listOf(games), "/storage/card/New"))
|
||||
}
|
||||
|
||||
@Test fun aGamesFolderRemainsDiscoverableBesideChosenGameStorage() {
|
||||
val card = tmp.newFolder("card")
|
||||
val games = File(card, "GameNative").path
|
||||
val selected = File(card, "Selected").apply { mkdirs() }
|
||||
SessionPrefs.setGameStorage(app, selected.path, "Selected")
|
||||
val effective = GameStorage.effective(app)!!
|
||||
assertTrue(SteamLibraries.offered(listOf(effective.path), listOf(games), games))
|
||||
SessionPrefs.setGameStorage(app, card.path, "Card")
|
||||
assertFalse(SteamLibraries.offered(listOf(GameStorage.effective(app)!!.path), listOf(games), games))
|
||||
}
|
||||
|
||||
private fun library(dir: File): File = dir.apply { File(this, "steamapps").mkdirs(); File(this, "steamapps/appmanifest_220.acf").writeText("x") }
|
||||
|
||||
@Test fun pickingTheFolderAboveALibraryAddsTheLibraryInside() {
|
||||
@@ -124,6 +144,14 @@ class SteamLibrariesTest {
|
||||
assertEquals("${lib.guest}/steamapps/common/Game", AddedGames.guestPath(app, scanned.folder))
|
||||
}
|
||||
|
||||
@Test fun rawAndStorageMountViewsOverlapButDistinctFoldersDoNot() {
|
||||
val raw = SteamLibraries.canonical(File("/mnt/media_rw/ABCD-1234/Games"))
|
||||
val storage = SteamLibraries.canonical(File("/storage/ABCD-1234/Games"))
|
||||
assertEquals(storage, raw)
|
||||
assertTrue(SteamLibraries.overlaps(raw, SteamLibraries.canonical(File("/storage/ABCD-1234/Games/Steam"))))
|
||||
assertFalse(SteamLibraries.overlaps(raw, SteamLibraries.canonical(File("/storage/ABCD-1234/Other"))))
|
||||
}
|
||||
|
||||
@Test fun unreadableOrInvalidEntriesAreDropped() {
|
||||
assertTrue(SteamLibraries.parse("{oops").isEmpty())
|
||||
assertEquals(listOf("2"), SteamLibraries.parse("""[{"id":"../x","path":"/a"},{"id":"2","path":"/b","label":""}]""").map { it.id })
|
||||
|
||||
Reference in new issue
Block a user