music: only compute song uid once

This commit is contained in:
Alexander Capehart 2024-11-27 09:46:59 -07:00
parent dd3b411beb
commit e0bbb88e92
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
3 changed files with 3 additions and 3 deletions

View file

@ -85,7 +85,7 @@ class InterpreterImpl @Inject constructor(private val preparer: Preparer) : Inte
val uidMap = mutableMapOf<Music.UID, SongImpl>()
val songs =
albumLinkedSongs.mapNotNull {
val uid = it.preSong.computeUid()
val uid = it.preSong.uid
val other = uidMap[uid]
if (other == null) {
SongImpl(it)

View file

@ -43,7 +43,7 @@ import org.oxycblt.auxio.util.update
class SongImpl(linkedSong: LinkedSong) : Song {
private val preSong = linkedSong.preSong
override val uid = preSong.computeUid()
override val uid = preSong.uid
override val name = preSong.name
override val track = preSong.track
override val disc = preSong.disc

View file

@ -52,7 +52,7 @@ data class PreSong(
val preArtists: List<PreArtist>,
val preGenres: List<PreGenre>
) {
fun computeUid() =
val uid =
musicBrainzId?.let { Music.UID.musicBrainz(MusicType.SONGS, it) }
?: Music.UID.auxio(MusicType.SONGS) {
// Song UIDs are based on the raw data without parsing so that they remain