fix(storage): a Second library on a raw /mnt/media_rw path is used again (#2245)

fix(storage): check a raw /mnt/media_rw library against its storage volume

A Second library picked as /mnt/media_rw/<volume>/... was always treated as
unplugged, because Android only reports a volume's state for its /storage
path. Sessions then ran with internal storage only and the library's games
were missing. Map the path to its /storage form before the lookup, reusing
UsbLink.storagePath, and drop the copy in SteamLibraries.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-07 19:32:13 -05:00
1 parent 10cfc6c6b2
commit 5b2f7a9a6d
3 files changed
+21 -7

No files matched your search

@@ -81,6 +81,20 @@ class GameStorageTest {
assertFalse(GameStorage.attached(volume, Environment.MEDIA_UNKNOWN, externalStoragePath = true))
}
@Test fun aRawVolumePathIsCheckedAsItsStorageVolume() {
val asked = mutableListOf<String>()
val mounted = { file: File -> asked += file.path; if (file.path.startsWith("/storage/B2BD-BCFC")) Environment.MEDIA_MOUNTED else Environment.MEDIA_UNKNOWN }
assertTrue(GameStorage.attached(File("/mnt/media_rw/B2BD-BCFC/STEAM GAMES"), mounted))
assertEquals("/storage/B2BD-BCFC/STEAM GAMES", asked.single())
assertTrue(GameStorage.attached(File("/storage/B2BD-BCFC/STEAM GAMES"), mounted))
}
@Test fun aRawVolumePathOnARemovedCardIsNotAttached() {
assertFalse(GameStorage.attached(File("/mnt/media_rw/B2BD-BCFC/STEAM GAMES")) { Environment.MEDIA_REMOVED })
assertFalse(GameStorage.attached(File("/mnt/media_rw/B2BD-BCFC/STEAM GAMES")) { Environment.MEDIA_UNKNOWN })
assertFalse(GameStorage.attached(File("/mnt/media_rw/B2BD-BCFC/STEAM GAMES")) { null })
}
@Test fun onlyASavedDriveThatIsMissingCountsAsDisconnected() {
SessionPrefs.setGameStorage(app, "", "")
assertFalse(GameStorage.disconnected(app))