mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
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:
1 parent
10cfc6c6b2
commit
5b2f7a9a6d
3 files changed
+21
-7
No files matched your search
@@ -57,8 +57,10 @@ object GameStorage {
|
||||
return pref.isNotEmpty() && pref != SessionPrefs.GAME_STORAGE_OFF && !attached(File(pref))
|
||||
}
|
||||
|
||||
internal fun attached(path: File): Boolean =
|
||||
attached(path, runCatching { Environment.getExternalStorageState(path) }.getOrNull())
|
||||
internal fun attached(
|
||||
path: File,
|
||||
stateOf: (File) -> String? = { runCatching { Environment.getExternalStorageState(it) }.getOrNull() },
|
||||
): Boolean = attached(path, stateOf(File(UsbLink.storagePath(path.path))))
|
||||
|
||||
internal fun attached(
|
||||
path: File,
|
||||
|
||||
@@ -96,7 +96,7 @@ object SteamLibraries {
|
||||
if (picked.none { overlaps(canonical(it.first), canonical(hit.first)) }) picked += hit
|
||||
}
|
||||
return picked.map { (dir, games) ->
|
||||
val shown = File(storagePath(dir.path))
|
||||
val shown = File(UsbLink.storagePath(dir.path))
|
||||
Found(dir.path, shown.path, defaultLabel(context, shown), games)
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ object SteamLibraries {
|
||||
}
|
||||
|
||||
fun defaultLabel(context: Context, picked: File): String {
|
||||
val folder = File(storagePath(picked.path))
|
||||
val folder = File(UsbLink.storagePath(picked.path))
|
||||
val volume = try {
|
||||
context.getSystemService(StorageManager::class.java)?.getStorageVolume(folder)?.getDescription(context)
|
||||
} catch (e: Exception) {
|
||||
@@ -171,9 +171,7 @@ object SteamLibraries {
|
||||
|
||||
internal fun overlaps(a: String, b: String): Boolean = a == b || a.startsWith("$b/") || b.startsWith("$a/")
|
||||
|
||||
private fun storagePath(path: String): String = if (path.startsWith("/mnt/media_rw/")) "/storage/" + path.removePrefix("/mnt/media_rw/") else path
|
||||
|
||||
private fun canonical(file: File): String = storagePath(runCatching { file.canonicalPath }.getOrDefault(file.absolutePath))
|
||||
private fun canonical(file: File): String = UsbLink.storagePath(runCatching { file.canonicalPath }.getOrDefault(file.absolutePath))
|
||||
|
||||
private const val SCAN_DEPTH = 2
|
||||
private const val SCAN_LIMIT = 4000
|
||||
|
||||
Reference in new issue
Block a user