From c4143e7d95df60551fdeacb9d384970a99c251d7 Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Fri, 5 Jan 2024 12:35:36 -0700 Subject: [PATCH] music: log when volume cannot be found Mostly for debugging purposes. --- .../oxycblt/auxio/music/fs/MediaStorePathInterpreter.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStorePathInterpreter.kt b/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStorePathInterpreter.kt index 1f821aaf4..3a0e8b138 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStorePathInterpreter.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStorePathInterpreter.kt @@ -21,6 +21,7 @@ package org.oxycblt.auxio.music.fs import android.database.Cursor import android.os.Build import android.provider.MediaStore +import org.oxycblt.auxio.util.logE /** * 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 } @@ -172,11 +175,15 @@ private constructor(private val cursor: Cursor, volumeManager: VolumeManager) : override fun extract(): Path? { // Find the StorageVolume whose MediaStore name corresponds to it. 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 // in manually. val relativePath = cursor.getString(relativePathIndex) 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) return Path(volume, components) }