all: fix merge issues
This commit is contained in:
parent
e2d28f98f4
commit
cd535eda2e
10 changed files with 29 additions and 36 deletions
|
@ -25,18 +25,18 @@ import org.oxycblt.auxio.image.CoverMode
|
||||||
import org.oxycblt.auxio.image.ImageSettings
|
import org.oxycblt.auxio.image.ImageSettings
|
||||||
import org.oxycblt.musikr.covers.Cover
|
import org.oxycblt.musikr.covers.Cover
|
||||||
import org.oxycblt.musikr.covers.Covers
|
import org.oxycblt.musikr.covers.Covers
|
||||||
|
import org.oxycblt.musikr.covers.FDCover
|
||||||
import org.oxycblt.musikr.covers.MutableCovers
|
import org.oxycblt.musikr.covers.MutableCovers
|
||||||
import org.oxycblt.musikr.covers.fs.FSCovers
|
|
||||||
import org.oxycblt.musikr.covers.fs.MutableFSCovers
|
|
||||||
import org.oxycblt.musikr.covers.embedded.CoverIdentifier
|
import org.oxycblt.musikr.covers.embedded.CoverIdentifier
|
||||||
import org.oxycblt.musikr.covers.embedded.CoverParams
|
import org.oxycblt.musikr.covers.embedded.CoverParams
|
||||||
import org.oxycblt.musikr.covers.embedded.FileCover
|
import org.oxycblt.musikr.covers.fs.FSCovers
|
||||||
|
import org.oxycblt.musikr.covers.fs.MutableFSCovers
|
||||||
|
|
||||||
interface SettingCovers {
|
interface SettingCovers {
|
||||||
suspend fun mutate(context: Context, revision: UUID): MutableCovers<out Cover>
|
suspend fun mutate(context: Context, revision: UUID): MutableCovers<out Cover>
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun immutable(context: Context): Covers<FileCover> =
|
fun immutable(context: Context): Covers<FDCover> =
|
||||||
Covers.chain(BaseSiloedCovers(context), FSCovers(context))
|
Covers.chain(BaseSiloedCovers(context), FSCovers(context))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,18 +25,18 @@ import kotlinx.coroutines.withContext
|
||||||
import org.oxycblt.musikr.covers.Cover
|
import org.oxycblt.musikr.covers.Cover
|
||||||
import org.oxycblt.musikr.covers.CoverResult
|
import org.oxycblt.musikr.covers.CoverResult
|
||||||
import org.oxycblt.musikr.covers.Covers
|
import org.oxycblt.musikr.covers.Covers
|
||||||
|
import org.oxycblt.musikr.covers.FDCover
|
||||||
import org.oxycblt.musikr.covers.MutableCovers
|
import org.oxycblt.musikr.covers.MutableCovers
|
||||||
import org.oxycblt.musikr.covers.embedded.CoverFormat
|
import org.oxycblt.musikr.covers.embedded.CoverFormat
|
||||||
import org.oxycblt.musikr.covers.embedded.CoverIdentifier
|
import org.oxycblt.musikr.covers.embedded.CoverIdentifier
|
||||||
import org.oxycblt.musikr.covers.embedded.FileCover
|
|
||||||
import org.oxycblt.musikr.covers.embedded.EmbeddedCovers
|
import org.oxycblt.musikr.covers.embedded.EmbeddedCovers
|
||||||
import org.oxycblt.musikr.covers.embedded.MutableEmbeddedCovers
|
import org.oxycblt.musikr.covers.embedded.MutableEmbeddedCovers
|
||||||
import org.oxycblt.musikr.fs.app.AppFS
|
import org.oxycblt.musikr.fs.app.AppFS
|
||||||
import org.oxycblt.musikr.fs.device.DeviceFile
|
import org.oxycblt.musikr.fs.device.DeviceFile
|
||||||
import org.oxycblt.musikr.metadata.Metadata
|
import org.oxycblt.musikr.metadata.Metadata
|
||||||
|
|
||||||
class BaseSiloedCovers(private val context: Context) : Covers<FileCover> {
|
class BaseSiloedCovers(private val context: Context) : Covers<FDCover> {
|
||||||
override suspend fun obtain(id: String): CoverResult<FileCover> {
|
override suspend fun obtain(id: String): CoverResult<FDCover> {
|
||||||
val siloedId = SiloedCoverId.parse(id) ?: return CoverResult.Miss()
|
val siloedId = SiloedCoverId.parse(id) ?: return CoverResult.Miss()
|
||||||
val core = SiloCore.from(context, siloedId.silo)
|
val core = SiloCore.from(context, siloedId.silo)
|
||||||
val embeddedCovers = EmbeddedCovers(core.files, core.format)
|
val embeddedCovers = EmbeddedCovers(core.files, core.format)
|
||||||
|
@ -48,8 +48,8 @@ class BaseSiloedCovers(private val context: Context) : Covers<FileCover> {
|
||||||
}
|
}
|
||||||
|
|
||||||
open class SiloedCovers(private val silo: CoverSilo, private val embeddedCovers: EmbeddedCovers) :
|
open class SiloedCovers(private val silo: CoverSilo, private val embeddedCovers: EmbeddedCovers) :
|
||||||
Covers<FileCover> {
|
Covers<FDCover> {
|
||||||
override suspend fun obtain(id: String): CoverResult<FileCover> {
|
override suspend fun obtain(id: String): CoverResult<FDCover> {
|
||||||
val coverId = SiloedCoverId.parse(id) ?: return CoverResult.Miss()
|
val coverId = SiloedCoverId.parse(id) ?: return CoverResult.Miss()
|
||||||
if (silo != coverId.silo) return CoverResult.Miss()
|
if (silo != coverId.silo) return CoverResult.Miss()
|
||||||
return when (val result = embeddedCovers.obtain(coverId.id)) {
|
return when (val result = embeddedCovers.obtain(coverId.id)) {
|
||||||
|
@ -71,8 +71,8 @@ private constructor(
|
||||||
private val rootDir: File,
|
private val rootDir: File,
|
||||||
private val silo: CoverSilo,
|
private val silo: CoverSilo,
|
||||||
private val fileCovers: MutableEmbeddedCovers
|
private val fileCovers: MutableEmbeddedCovers
|
||||||
) : SiloedCovers(silo, fileCovers), MutableCovers<FileCover> {
|
) : SiloedCovers(silo, fileCovers), MutableCovers<FDCover> {
|
||||||
override suspend fun create(file: DeviceFile, metadata: Metadata): CoverResult<FileCover> =
|
override suspend fun create(file: DeviceFile, metadata: Metadata): CoverResult<FDCover> =
|
||||||
when (val result = fileCovers.create(file, metadata)) {
|
when (val result = fileCovers.create(file, metadata)) {
|
||||||
is CoverResult.Hit -> CoverResult.Hit(SiloedCover(silo, result.cover))
|
is CoverResult.Hit -> CoverResult.Hit(SiloedCover(silo, result.cover))
|
||||||
is CoverResult.Miss -> CoverResult.Miss()
|
is CoverResult.Miss -> CoverResult.Miss()
|
||||||
|
@ -101,8 +101,8 @@ private constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SiloedCover(private val silo: CoverSilo, val innerCover: FileCover) :
|
data class SiloedCover(private val silo: CoverSilo, val innerCover: FDCover) :
|
||||||
FileCover by innerCover {
|
FDCover by innerCover {
|
||||||
private val innerId = SiloedCoverId(silo, innerCover.id)
|
private val innerId = SiloedCoverId(silo, innerCover.id)
|
||||||
override val id = innerId.toString()
|
override val id = innerId.toString()
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.oxycblt.musikr.MutableLibrary
|
||||||
import org.oxycblt.musikr.Playlist
|
import org.oxycblt.musikr.Playlist
|
||||||
import org.oxycblt.musikr.Song
|
import org.oxycblt.musikr.Song
|
||||||
import org.oxycblt.musikr.Storage
|
import org.oxycblt.musikr.Storage
|
||||||
import org.oxycblt.musikr.cache.db.MutableDBCache
|
import org.oxycblt.musikr.cache.MutableCache
|
||||||
import org.oxycblt.musikr.playlist.db.StoredPlaylists
|
import org.oxycblt.musikr.playlist.db.StoredPlaylists
|
||||||
import org.oxycblt.musikr.tag.interpret.Naming
|
import org.oxycblt.musikr.tag.interpret.Naming
|
||||||
import org.oxycblt.musikr.tag.interpret.Separators
|
import org.oxycblt.musikr.tag.interpret.Separators
|
||||||
|
@ -237,7 +237,7 @@ class MusicRepositoryImpl
|
||||||
@Inject
|
@Inject
|
||||||
constructor(
|
constructor(
|
||||||
@ApplicationContext private val context: Context,
|
@ApplicationContext private val context: Context,
|
||||||
private val dbCache: MutableDBCache,
|
private val cache: MutableCache,
|
||||||
private val storedPlaylists: StoredPlaylists,
|
private val storedPlaylists: StoredPlaylists,
|
||||||
private val settingCovers: SettingCovers,
|
private val settingCovers: SettingCovers,
|
||||||
private val musicSettings: MusicSettings
|
private val musicSettings: MusicSettings
|
||||||
|
@ -389,7 +389,7 @@ constructor(
|
||||||
|
|
||||||
val currentRevision = musicSettings.revision
|
val currentRevision = musicSettings.revision
|
||||||
val newRevision = currentRevision?.takeIf { withCache } ?: UUID.randomUUID()
|
val newRevision = currentRevision?.takeIf { withCache } ?: UUID.randomUUID()
|
||||||
val cache = if (withCache) dbCache else WriteOnlyMutableCache(dbCache)
|
val cache = if (withCache) cache else WriteOnlyMutableCache(cache)
|
||||||
val covers = settingCovers.mutate(context, newRevision)
|
val covers = settingCovers.mutate(context, newRevision)
|
||||||
val storage = Storage(cache, covers, storedPlaylists)
|
val storage = Storage(cache, covers, storedPlaylists)
|
||||||
val interpretation = Interpretation(nameFactory, separators, withHidden)
|
val interpretation = Interpretation(nameFactory, separators, withHidden)
|
||||||
|
|
|
@ -25,6 +25,7 @@ import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
import org.oxycblt.musikr.cache.MutableCache
|
||||||
import org.oxycblt.musikr.cache.db.MutableDBCache
|
import org.oxycblt.musikr.cache.db.MutableDBCache
|
||||||
import org.oxycblt.musikr.playlist.db.StoredPlaylists
|
import org.oxycblt.musikr.playlist.db.StoredPlaylists
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ import org.oxycblt.musikr.playlist.db.StoredPlaylists
|
||||||
class MusikrShimModule {
|
class MusikrShimModule {
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
fun cache(@ApplicationContext context: Context) = MutableDBCache.from(context)
|
fun cache(@ApplicationContext context: Context): MutableCache = MutableDBCache.from(context)
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2025 Auxio Project
|
* Copyright (c) 2025 Auxio Project
|
||||||
* InternalCovers.kt is part of Auxio.
|
* EmbeddedCovers.kt is part of Auxio.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -23,8 +23,6 @@ import android.net.Uri
|
||||||
import android.os.ParcelFileDescriptor
|
import android.os.ParcelFileDescriptor
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.firstOrNull
|
|
||||||
import kotlinx.coroutines.flow.mapNotNull
|
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.oxycblt.musikr.covers.Cover
|
import org.oxycblt.musikr.covers.Cover
|
||||||
import org.oxycblt.musikr.covers.CoverResult
|
import org.oxycblt.musikr.covers.CoverResult
|
||||||
|
@ -76,10 +74,7 @@ class MutableFSCovers(private val context: Context) : FSCovers(context), Mutable
|
||||||
|
|
||||||
private fun findCoverInDirectory(directory: DeviceDirectory): DeviceFile? {
|
private fun findCoverInDirectory(directory: DeviceDirectory): DeviceFile? {
|
||||||
return directory.children.firstNotNullOfOrNull { node ->
|
return directory.children.firstNotNullOfOrNull { node ->
|
||||||
if (node is DeviceFile && isCoverArtFile(
|
if (node is DeviceFile && isCoverArtFile(node)) node else null
|
||||||
node
|
|
||||||
)
|
|
||||||
) node else null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.oxycblt.musikr.fs.device
|
package org.oxycblt.musikr.fs.device
|
||||||
|
|
||||||
import android.content.ContentResolver
|
import android.content.ContentResolver
|
||||||
|
@ -75,8 +75,7 @@ private class DeviceFSImpl(
|
||||||
location.uri,
|
location.uri,
|
||||||
DocumentsContract.getTreeDocumentId(location.uri),
|
DocumentsContract.getTreeDocumentId(location.uri),
|
||||||
location.path,
|
location.path,
|
||||||
null
|
null)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun exploreDirectoryImpl(
|
private fun exploreDirectoryImpl(
|
||||||
|
@ -116,8 +115,7 @@ private class DeviceFSImpl(
|
||||||
|
|
||||||
if (mimeType == DocumentsContract.Document.MIME_TYPE_DIR) {
|
if (mimeType == DocumentsContract.Document.MIME_TYPE_DIR) {
|
||||||
recursive.add(
|
recursive.add(
|
||||||
exploreDirectoryImpl(rootUri, childId, newPath, directoryDeferred)
|
exploreDirectoryImpl(rootUri, childId, newPath, directoryDeferred))
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
val size = cursor.getLong(sizeIndex)
|
val size = cursor.getLong(sizeIndex)
|
||||||
val childUri = DocumentsContract.buildDocumentUriUsingTree(rootUri, childId)
|
val childUri = DocumentsContract.buildDocumentUriUsingTree(rootUri, childId)
|
||||||
|
@ -128,8 +126,7 @@ private class DeviceFSImpl(
|
||||||
path = newPath,
|
path = newPath,
|
||||||
size = size,
|
size = size,
|
||||||
modifiedMs = lastModified,
|
modifiedMs = lastModified,
|
||||||
parent = directoryDeferred
|
parent = directoryDeferred)
|
||||||
)
|
|
||||||
children.add(file)
|
children.add(file)
|
||||||
emit(file)
|
emit(file)
|
||||||
}
|
}
|
||||||
|
@ -146,7 +143,6 @@ private class DeviceFSImpl(
|
||||||
DocumentsContract.Document.COLUMN_DISPLAY_NAME,
|
DocumentsContract.Document.COLUMN_DISPLAY_NAME,
|
||||||
DocumentsContract.Document.COLUMN_MIME_TYPE,
|
DocumentsContract.Document.COLUMN_MIME_TYPE,
|
||||||
DocumentsContract.Document.COLUMN_SIZE,
|
DocumentsContract.Document.COLUMN_SIZE,
|
||||||
DocumentsContract.Document.COLUMN_LAST_MODIFIED
|
DocumentsContract.Document.COLUMN_LAST_MODIFIED)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.oxycblt.musikr.pipeline
|
||||||
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.filterIsInstance
|
import kotlinx.coroutines.flow.filterIsInstance
|
||||||
import kotlinx.coroutines.flow.fold
|
|
||||||
import org.oxycblt.musikr.Interpretation
|
import org.oxycblt.musikr.Interpretation
|
||||||
import org.oxycblt.musikr.MutableLibrary
|
import org.oxycblt.musikr.MutableLibrary
|
||||||
import org.oxycblt.musikr.Storage
|
import org.oxycblt.musikr.Storage
|
||||||
|
|
|
@ -67,7 +67,9 @@ private class ExploreStepImpl(
|
||||||
val addingMs = System.currentTimeMillis()
|
val addingMs = System.currentTimeMillis()
|
||||||
return merge(
|
return merge(
|
||||||
deviceFS
|
deviceFS
|
||||||
.explore(locations.asFlow(),)
|
.explore(
|
||||||
|
locations.asFlow(),
|
||||||
|
)
|
||||||
.filter { it.mimeType.startsWith("audio/") || it.mimeType == M3U.MIME_TYPE }
|
.filter { it.mimeType.startsWith("audio/") || it.mimeType == M3U.MIME_TYPE }
|
||||||
.distribute(8)
|
.distribute(8)
|
||||||
.distributedMap { file ->
|
.distributedMap { file ->
|
||||||
|
|
|
@ -72,4 +72,4 @@ internal suspend fun <T, A> Flow<T>.tryFold(initial: A, operation: suspend (A, T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return accumulator
|
return accumulator
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue