musikr: fix dupliate artist vertices when melding
This commit is contained in:
parent
3d154ea66c
commit
a1d62c2a08
1 changed files with 14 additions and 6 deletions
|
@ -243,14 +243,22 @@ private class MusicGraphBuilderImpl : MusicGraph.Builder {
|
||||||
dst.genreVertices.addAll(src.genreVertices)
|
dst.genreVertices.addAll(src.genreVertices)
|
||||||
// Update all songs, albums, and genres to point to the relevant artist.
|
// Update all songs, albums, and genres to point to the relevant artist.
|
||||||
src.songVertices.forEach {
|
src.songVertices.forEach {
|
||||||
val index = it.artistVertices.indexOf(src)
|
// There can be duplicate artist vertices that we need to
|
||||||
check(index >= 0) { "Illegal state: directed edge between artist and song" }
|
// all replace when melding.
|
||||||
it.artistVertices[index] = dst
|
for (idx in it.artistVertices.indices) {
|
||||||
|
if (it.artistVertices[idx] == src) {
|
||||||
|
it.artistVertices[idx] = dst
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
src.albumVertices.forEach {
|
src.albumVertices.forEach {
|
||||||
val index = it.artistVertices.indexOf(src)
|
// There can be duplicate artist vertices that we need to
|
||||||
check(index >= 0) { "Illegal state: directed edge between artist and album" }
|
// all replace when melding.
|
||||||
it.artistVertices[index] = dst
|
for (idx in it.artistVertices.indices) {
|
||||||
|
if (it.artistVertices[idx] == src) {
|
||||||
|
it.artistVertices[idx] = dst
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
src.genreVertices.forEach {
|
src.genreVertices.forEach {
|
||||||
it.artistVertices.remove(src)
|
it.artistVertices.remove(src)
|
||||||
|
|
Loading…
Reference in a new issue