diff --git a/app/src/main/java/org/oxycblt/auxio/image/stack/StackModule.kt b/app/src/main/java/org/oxycblt/auxio/image/stack/StackModule.kt
index 97fd5ff7a..4fc3c5eb8 100644
--- a/app/src/main/java/org/oxycblt/auxio/image/stack/StackModule.kt
+++ b/app/src/main/java/org/oxycblt/auxio/image/stack/StackModule.kt
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2024 Auxio Project
- * MusikrModule.kt is part of Auxio.
+ * StackModule.kt is part of Auxio.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt
index 026b33604..df849322a 100644
--- a/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt
+++ b/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt
@@ -25,10 +25,10 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.withContext
import kotlinx.coroutines.yield
import org.oxycblt.auxio.music.MusicRepository.IndexingWorker
-import org.oxycblt.musikr.Musikr
import org.oxycblt.musikr.IndexingProgress
import org.oxycblt.musikr.Library
import org.oxycblt.musikr.Music
+import org.oxycblt.musikr.Musikr
import org.oxycblt.musikr.MutableLibrary
import org.oxycblt.musikr.Playlist
import org.oxycblt.musikr.Song
diff --git a/app/src/main/java/org/oxycblt/musikr/Library.kt b/app/src/main/java/org/oxycblt/musikr/Library.kt
index 3facdeff5..c5d73312f 100644
--- a/app/src/main/java/org/oxycblt/musikr/Library.kt
+++ b/app/src/main/java/org/oxycblt/musikr/Library.kt
@@ -1,8 +1,25 @@
+/*
+ * Copyright (c) 2024 Auxio Project
+ * Library.kt is part of Auxio.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
package org.oxycblt.musikr
import org.oxycblt.musikr.fs.Path
-
interface Library {
val songs: Collection
val albums: Collection
diff --git a/app/src/main/java/org/oxycblt/musikr/Musikr.kt b/app/src/main/java/org/oxycblt/musikr/Musikr.kt
index 3257db05e..33ab5fd27 100644
--- a/app/src/main/java/org/oxycblt/musikr/Musikr.kt
+++ b/app/src/main/java/org/oxycblt/musikr/Musikr.kt
@@ -63,13 +63,13 @@ constructor(
onProgress: suspend (IndexingProgress) -> Unit
) = coroutineScope {
var exploredCount = 0
+ var extractedCount = 0
val explored =
exploreStep
.explore(locations)
.buffer(Channel.UNLIMITED)
.onStart { onProgress(IndexingProgress.Songs(0, 0)) }
- .onEach { onProgress(IndexingProgress.Songs(0, ++exploredCount)) }
- var extractedCount = 0
+ .onEach { onProgress(IndexingProgress.Songs(extractedCount, ++exploredCount)) }
val extracted =
extractStep
.extract(explored)
diff --git a/app/src/main/java/org/oxycblt/musikr/cover/Cover.kt b/app/src/main/java/org/oxycblt/musikr/cover/Cover.kt
index 2d7d332c2..7babc0a95 100644
--- a/app/src/main/java/org/oxycblt/musikr/cover/Cover.kt
+++ b/app/src/main/java/org/oxycblt/musikr/cover/Cover.kt
@@ -38,7 +38,7 @@ sealed interface Cover {
}
companion object {
- private val FALLBACK_SORT = Sort(Sort.Mode.ByAlbum, Sort.Direction.ASCENDING)
+ private val FALLBACK_SORT = Sort(Sort.Mode.ByName, Sort.Direction.ASCENDING)
fun nil() = Multi(listOf())
diff --git a/app/src/main/java/org/oxycblt/musikr/graph/MusicGraph.kt b/app/src/main/java/org/oxycblt/musikr/graph/MusicGraph.kt
index e2ba42557..b7f8af828 100644
--- a/app/src/main/java/org/oxycblt/musikr/graph/MusicGraph.kt
+++ b/app/src/main/java/org/oxycblt/musikr/graph/MusicGraph.kt
@@ -211,7 +211,7 @@ private class MusicGraphBuilderImpl : MusicGraph.Builder {
// Link all songs and albums from the irrelevant artist to the relevant artist.
dst.songVertices.addAll(src.songVertices)
dst.albumVertices.addAll(src.albumVertices)
- // Update all songs and albums to point to the relevant artist.
+ // Update all songs, albums, and genres to point to the relevant artist.
src.songVertices.forEach {
val index = it.artistVertices.indexOf(src)
check(index >= 0) { "Illegal state: directed edge between artist and song" }
@@ -222,6 +222,11 @@ private class MusicGraphBuilderImpl : MusicGraph.Builder {
check(index >= 0) { "Illegal state: directed edge between artist and album" }
it.artistVertices[index] = dst
}
+ src.genreVertices.forEach {
+ it.artistVertices.remove(src)
+ it.artistVertices.add(dst)
+ }
+
// Remove the irrelevant artist from the graph.
artistVertices.remove(src.preArtist)
}
diff --git a/app/src/main/java/org/oxycblt/musikr/pipeline/ExtractStep.kt b/app/src/main/java/org/oxycblt/musikr/pipeline/ExtractStep.kt
index 79f37c231..a4d43292f 100644
--- a/app/src/main/java/org/oxycblt/musikr/pipeline/ExtractStep.kt
+++ b/app/src/main/java/org/oxycblt/musikr/pipeline/ExtractStep.kt
@@ -70,10 +70,18 @@ constructor(
.flowOn(Dispatchers.IO)
.buffer(Channel.UNLIMITED)
}
+ val writtenSongs =
+ merge(*extractedSongs)
+ .map {
+ tagCache.write(it.file, it.tags)
+ it
+ }
+ .flowOn(Dispatchers.IO)
+ .buffer(Channel.UNLIMITED)
return merge(
cachedSongs,
split.cold,
- *extractedSongs,
+ writtenSongs,
)
}
diff --git a/app/src/main/java/org/oxycblt/musikr/pipeline/FlowUtil.kt b/app/src/main/java/org/oxycblt/musikr/pipeline/FlowUtil.kt
index 96bb3143e..4ec4d8f56 100644
--- a/app/src/main/java/org/oxycblt/musikr/pipeline/FlowUtil.kt
+++ b/app/src/main/java/org/oxycblt/musikr/pipeline/FlowUtil.kt
@@ -40,6 +40,7 @@ inline fun Flow.mapPartition(crossinline predicate: (T) -> R?): HotCol
emit(it)
}
}
+ passChannel.close()
}
return HotCold(passFlow, failFlow)
}