music: deduplicate by case

At some point, the switch to keying raw music information broke my
mitigation for duplicate tags that use similar cases. This then
crashed the music loader in certain cases. Fix it by making the
check use raw music keys.

Resolves #614
This commit is contained in:
Alexander Capehart 2023-12-16 13:52:36 -07:00
parent 7a90e7eef1
commit 4421d6cf36
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -150,26 +150,26 @@ class SongImpl(
val artistSortNames = separators.split(rawSong.artistSortNames)
val rawIndividualArtists =
artistNames
.mapIndexedTo(mutableSetOf()) { i, name ->
.mapIndexed { i, name ->
RawArtist(
artistMusicBrainzIds.getOrNull(i)?.toUuidOrNull(),
name,
artistSortNames.getOrNull(i))
}
.toList()
.distinctBy { it.key }
val albumArtistMusicBrainzIds = separators.split(rawSong.albumArtistMusicBrainzIds)
val albumArtistNames = separators.split(rawSong.albumArtistNames)
val albumArtistSortNames = separators.split(rawSong.albumArtistSortNames)
val rawAlbumArtists =
albumArtistNames
.mapIndexedTo(mutableSetOf()) { i, name ->
.mapIndexed { i, name ->
RawArtist(
albumArtistMusicBrainzIds.getOrNull(i)?.toUuidOrNull(),
name,
albumArtistSortNames.getOrNull(i))
}
.toList()
.distinctBy { it.key }
rawAlbum =
RawAlbum(
@ -195,10 +195,7 @@ class SongImpl(
val genreNames =
(rawSong.genreNames.parseId3GenreNames() ?: separators.split(rawSong.genreNames))
rawGenres =
genreNames
.mapTo(mutableSetOf()) { RawGenre(it) }
.toList()
.ifEmpty { listOf(RawGenre()) }
genreNames.map { RawGenre(it) }.distinctBy { it.key }.ifEmpty { listOf(RawGenre()) }
hashCode = 31 * hashCode + rawSong.hashCode()
hashCode = 31 * hashCode + nameFactory.hashCode()