musikr: compute uid on presong creation

This commit is contained in:
Alexander Capehart 2024-12-24 15:08:49 -05:00
parent 7768d98632
commit c42ac644eb
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
3 changed files with 16 additions and 17 deletions

View file

@ -55,7 +55,7 @@ private class MusicGraphBuilderImpl : MusicGraph.Builder {
private val playlistVertices = mutableSetOf<PlaylistVertex>() private val playlistVertices = mutableSetOf<PlaylistVertex>()
override fun add(preSong: PreSong) { override fun add(preSong: PreSong) {
val uid = preSong.computeUid() val uid = preSong.uid
if (songVertices.containsKey(uid)) { if (songVertices.containsKey(uid)) {
return return
} }

View file

@ -42,7 +42,7 @@ internal interface SongCore {
internal class SongImpl(private val handle: SongCore) : Song { internal class SongImpl(private val handle: SongCore) : Song {
private val preSong = handle.preSong private val preSong = handle.preSong
override val uid = preSong.computeUid() override val uid = preSong.uid
override val name = preSong.name override val name = preSong.name
override val track = preSong.track override val track = preSong.track
override val disc = preSong.disc override val disc = preSong.disc

View file

@ -53,8 +53,7 @@ internal data class PreSong(
val preArtists: List<PreArtist>, val preArtists: List<PreArtist>,
val preGenres: List<PreGenre> val preGenres: List<PreGenre>
) { ) {
fun computeUid() = val uid = musicBrainzId?.let { Music.UID.musicBrainz(Music.UID.Item.SONG, it) }
musicBrainzId?.let { Music.UID.musicBrainz(Music.UID.Item.SONG, it) }
?: Music.UID.auxio(Music.UID.Item.SONG) { ?: Music.UID.auxio(Music.UID.Item.SONG) {
// Song UIDs are based on the raw data without parsing so that they remain // Song UIDs are based on the raw data without parsing so that they remain
// consistent across music setting changes. Parents are not held up to the // consistent across music setting changes. Parents are not held up to the