Skip to content

Commit

Permalink
music: deduplicate by case
Browse files Browse the repository at this point in the history
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
  • Loading branch information
OxygenCobalt committed Dec 16, 2023
1 parent 7a90e7e commit 4421d6c
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()
Expand Down

0 comments on commit 4421d6c

Please sign in to comment.