music: log when volume cannot be found

Mostly for debugging purposes.
This commit is contained in:
Alexander Capehart 2024-01-05 12:35:36 -07:00
parent 19bfd758a6
commit c4143e7d95
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -21,6 +21,7 @@ package org.oxycblt.auxio.music.fs
import android.database.Cursor import android.database.Cursor
import android.os.Build import android.os.Build
import android.provider.MediaStore import android.provider.MediaStore
import org.oxycblt.auxio.util.logE
/** /**
* Wrapper around a [Cursor] that interprets path information on a per-API/manufacturer basis. * Wrapper around a [Cursor] that interprets path information on a per-API/manufacturer basis.
@ -111,6 +112,8 @@ private constructor(private val cursor: Cursor, volumeManager: VolumeManager) :
} }
} }
logE("Could not find volume for $data [tried: ${volumes.map { it.components }}]")
return null return null
} }
@ -172,11 +175,15 @@ private constructor(private val cursor: Cursor, volumeManager: VolumeManager) :
override fun extract(): Path? { override fun extract(): Path? {
// Find the StorageVolume whose MediaStore name corresponds to it. // Find the StorageVolume whose MediaStore name corresponds to it.
val volumeName = cursor.getString(volumeIndex) val volumeName = cursor.getString(volumeIndex)
val volume = volumes.find { it.mediaStoreName == volumeName } ?: return null
// Relative path does not include file name, must use DISPLAY_NAME and add it // Relative path does not include file name, must use DISPLAY_NAME and add it
// in manually. // in manually.
val relativePath = cursor.getString(relativePathIndex) val relativePath = cursor.getString(relativePathIndex)
val displayName = cursor.getString(displayNameIndex) val displayName = cursor.getString(displayNameIndex)
val volume = volumes.find { it.mediaStoreName == volumeName }
if (volume == null) {
logE("Could not find volume for $volumeName:$relativePath/$displayName [tried: ${volumes.map { it.mediaStoreName }}]")
return null
}
val components = Components.parseUnix(relativePath).child(displayName) val components = Components.parseUnix(relativePath).child(displayName)
return Path(volume, components) return Path(volume, components)
} }