music: handle duplicate artist/genre values
Remove functionally duplicate artist/genre values that were read from a file. This caused a indexer crash in 3.1.2 due to the switch to music sets, which no longer made duplicate values group the song twice. This then cascaded to a failure in song finalization, as it expects there to be the same amount of artists/genres as raw artists/genres.
This commit is contained in:
parent
5bda85fe36
commit
6f6a3d8d31
1 changed files with 9 additions and 2 deletions
|
@ -152,6 +152,7 @@ class SongImpl(private val rawSong: RawSong, musicSettings: MusicSettings) : Son
|
|||
rawArtists =
|
||||
rawAlbumArtists
|
||||
.ifEmpty { rawIndividualArtists }
|
||||
.distinctBy { it.key }
|
||||
.ifEmpty { listOf(RawArtist(null, null)) })
|
||||
|
||||
/**
|
||||
|
@ -160,7 +161,10 @@ class SongImpl(private val rawSong: RawSong, musicSettings: MusicSettings) : Son
|
|||
* [RawArtist]. This can be used to group up [Song]s into an [Artist].
|
||||
*/
|
||||
val rawArtists =
|
||||
rawIndividualArtists.ifEmpty { rawAlbumArtists }.ifEmpty { listOf(RawArtist()) }
|
||||
rawIndividualArtists
|
||||
.ifEmpty { rawAlbumArtists }
|
||||
.distinctBy { it.key }
|
||||
.ifEmpty { listOf(RawArtist()) }
|
||||
|
||||
/**
|
||||
* The [RawGenre] instances collated by the [Song]. This can be used to group up [Song]s into a
|
||||
|
@ -170,6 +174,7 @@ class SongImpl(private val rawSong: RawSong, musicSettings: MusicSettings) : Son
|
|||
rawSong.genreNames
|
||||
.parseId3GenreNames(musicSettings)
|
||||
.map { RawGenre(it) }
|
||||
.distinctBy { it.key }
|
||||
.ifEmpty { listOf(RawGenre()) }
|
||||
|
||||
/**
|
||||
|
@ -208,6 +213,7 @@ class SongImpl(private val rawSong: RawSong, musicSettings: MusicSettings) : Son
|
|||
checkNotNull(_album) { "Malformed song: No album" }
|
||||
|
||||
check(_artists.isNotEmpty()) { "Malformed song: No artists" }
|
||||
check(_artists.size == rawArtists.size) { "Malformed song: Artist grouping mismatch" }
|
||||
for (i in _artists.indices) {
|
||||
// Non-destructively reorder the linked artists so that they align with
|
||||
// the artist ordering within the song metadata.
|
||||
|
@ -218,7 +224,7 @@ class SongImpl(private val rawSong: RawSong, musicSettings: MusicSettings) : Son
|
|||
}
|
||||
|
||||
check(_genres.isNotEmpty()) { "Malformed song: No genres" }
|
||||
logD("$this $rawGenres $_genres]")
|
||||
check(_genres.size == rawGenres.size) { "Malformed song: Genre grouping mismatch"}
|
||||
for (i in _genres.indices) {
|
||||
// Non-destructively reorder the linked genres so that they align with
|
||||
// the genre ordering within the song metadata.
|
||||
|
@ -336,6 +342,7 @@ class AlbumImpl(
|
|||
fun finalize(): Album {
|
||||
check(songs.isNotEmpty()) { "Malformed album: Empty" }
|
||||
check(_artists.isNotEmpty()) { "Malformed album: No artists" }
|
||||
check(_artists.size == rawArtists.size) { "Malformed song: Artist grouping mismatch" }
|
||||
for (i in _artists.indices) {
|
||||
// Non-destructively reorder the linked artists so that they align with
|
||||
// the artist ordering within the song metadata.
|
||||
|
|
Loading…
Reference in a new issue