Skip to content

Commit

Permalink
music: log when volume cannot be found
Browse files Browse the repository at this point in the history
Mostly for debugging purposes.
  • Loading branch information
OxygenCobalt committed Jan 5, 2024
1 parent 19bfd75 commit c4143e7
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit c4143e7

Please sign in to comment.