From 82a015c1e121c61a74972fc3214ed4b435e6f0a4 Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Fri, 5 Jul 2024 17:32:39 -0600 Subject: [PATCH] music: handle null mediastore album name Mostly a band-aid to make null album names correspond to a folder name (the standard MediaStore behavior). --- .../java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt b/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt index e0e989133..d0776e4a6 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt @@ -283,7 +283,10 @@ private class MediaStoreExtractorImpl( // the file is not actually in the root internal storage directory. We can't do // anything to fix this, really. We also can't really filter it out, since how can we // know when it corresponds to the folder and not, say, Low Roar's breakout album "0"? - rawSong.albumName = cursor.getString(albumIndex) + // Also, on some devices it's literally just null. To maintain behavior sanity just + // replicate the majority behavior described prior. + rawSong.albumName = cursor.getStringOrNull(albumIndex) + ?: requireNotNull(rawSong.path?.name) { "Invalid raw: No path" } // Android does not make a non-existent artist tag null, it instead fills it in // as , which makes absolutely no sense given how other columns default // to null if they are not present. If this column is such, null it so that