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.musikr.covers.Cover
|
||||
import org.oxycblt.musikr.covers.Covers
|
||||
import org.oxycblt.musikr.covers.FDCover
|
||||
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.CoverParams
|
||||
import org.oxycblt.musikr.covers.embedded.FileCover
|
||||
import org.oxycblt.musikr.covers.fs.FSCovers
|
||||
import org.oxycblt.musikr.covers.fs.MutableFSCovers
|
||||
|
||||
interface SettingCovers {
|
||||
suspend fun mutate(context: Context, revision: UUID): MutableCovers<out Cover>
|
||||
|
||||
companion object {
|
||||
fun immutable(context: Context): Covers<FileCover> =
|
||||
fun immutable(context: Context): Covers<FDCover> =
|
||||
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.CoverResult
|
||||
import org.oxycblt.musikr.covers.Covers
|
||||
import org.oxycblt.musikr.covers.FDCover
|
||||
import org.oxycblt.musikr.covers.MutableCovers
|
||||
import org.oxycblt.musikr.covers.embedded.CoverFormat
|
||||
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.MutableEmbeddedCovers
|
||||
import org.oxycblt.musikr.fs.app.AppFS
|
||||
import org.oxycblt.musikr.fs.device.DeviceFile
|
||||
import org.oxycblt.musikr.metadata.Metadata
|
||||
|
||||
class BaseSiloedCovers(private val context: Context) : Covers<FileCover> {
|
||||
override suspend fun obtain(id: String): CoverResult<FileCover> {
|
||||
class BaseSiloedCovers(private val context: Context) : Covers<FDCover> {
|
||||
override suspend fun obtain(id: String): CoverResult<FDCover> {
|
||||
val siloedId = SiloedCoverId.parse(id) ?: return CoverResult.Miss()
|
||||
val core = SiloCore.from(context, siloedId.silo)
|
||||
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) :
|
||||
Covers<FileCover> {
|
||||
override suspend fun obtain(id: String): CoverResult<FileCover> {
|
||||
Covers<FDCover> {
|
||||
override suspend fun obtain(id: String): CoverResult<FDCover> {
|
||||
val coverId = SiloedCoverId.parse(id) ?: return CoverResult.Miss()
|
||||
if (silo != coverId.silo) return CoverResult.Miss()
|
||||
return when (val result = embeddedCovers.obtain(coverId.id)) {
|
||||
|
@ -71,8 +71,8 @@ private constructor(
|
|||
private val rootDir: File,
|
||||
private val silo: CoverSilo,
|
||||
private val fileCovers: MutableEmbeddedCovers
|
||||
) : SiloedCovers(silo, fileCovers), MutableCovers<FileCover> {
|
||||
override suspend fun create(file: DeviceFile, metadata: Metadata): CoverResult<FileCover> =
|
||||
) : SiloedCovers(silo, fileCovers), MutableCovers<FDCover> {
|
||||
override suspend fun create(file: DeviceFile, metadata: Metadata): CoverResult<FDCover> =
|
||||
when (val result = fileCovers.create(file, metadata)) {
|
||||
is CoverResult.Hit -> CoverResult.Hit(SiloedCover(silo, result.cover))
|
||||
is CoverResult.Miss -> CoverResult.Miss()
|
||||
|
@ -101,8 +101,8 @@ private constructor(
|
|||
}
|
||||
}
|
||||
|
||||
data class SiloedCover(private val silo: CoverSilo, val innerCover: FileCover) :
|
||||
FileCover by innerCover {
|
||||
data class SiloedCover(private val silo: CoverSilo, val innerCover: FDCover) :
|
||||
FDCover by innerCover {
|
||||
private val innerId = SiloedCoverId(silo, innerCover.id)
|
||||
override val id = innerId.toString()
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.oxycblt.musikr.MutableLibrary
|
|||
import org.oxycblt.musikr.Playlist
|
||||
import org.oxycblt.musikr.Song
|
||||
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.tag.interpret.Naming
|
||||
import org.oxycblt.musikr.tag.interpret.Separators
|
||||
|
@ -237,7 +237,7 @@ class MusicRepositoryImpl
|
|||
@Inject
|
||||
constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
private val dbCache: MutableDBCache,
|
||||
private val cache: MutableCache,
|
||||
private val storedPlaylists: StoredPlaylists,
|
||||
private val settingCovers: SettingCovers,
|
||||
private val musicSettings: MusicSettings
|
||||
|
@ -389,7 +389,7 @@ constructor(
|
|||
|
||||
val currentRevision = musicSettings.revision
|
||||
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 storage = Storage(cache, covers, storedPlaylists)
|
||||
val interpretation = Interpretation(nameFactory, separators, withHidden)
|
||||
|
|
|
@ -25,6 +25,7 @@ import dagger.hilt.InstallIn
|
|||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
import org.oxycblt.musikr.cache.MutableCache
|
||||
import org.oxycblt.musikr.cache.db.MutableDBCache
|
||||
import org.oxycblt.musikr.playlist.db.StoredPlaylists
|
||||
|
||||
|
@ -33,7 +34,7 @@ import org.oxycblt.musikr.playlist.db.StoredPlaylists
|
|||
class MusikrShimModule {
|
||||
@Singleton
|
||||
@Provides
|
||||
fun cache(@ApplicationContext context: Context) = MutableDBCache.from(context)
|
||||
fun cache(@ApplicationContext context: Context): MutableCache = MutableDBCache.from(context)
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* 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
|
||||
* 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 java.io.InputStream
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.oxycblt.musikr.covers.Cover
|
||||
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? {
|
||||
return directory.children.firstNotNullOfOrNull { node ->
|
||||
if (node is DeviceFile && isCoverArtFile(
|
||||
node
|
||||
)
|
||||
) node else null
|
||||
if (node is DeviceFile && isCoverArtFile(node)) node else null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,8 +75,7 @@ private class DeviceFSImpl(
|
|||
location.uri,
|
||||
DocumentsContract.getTreeDocumentId(location.uri),
|
||||
location.path,
|
||||
null
|
||||
)
|
||||
null)
|
||||
}
|
||||
|
||||
private fun exploreDirectoryImpl(
|
||||
|
@ -116,8 +115,7 @@ private class DeviceFSImpl(
|
|||
|
||||
if (mimeType == DocumentsContract.Document.MIME_TYPE_DIR) {
|
||||
recursive.add(
|
||||
exploreDirectoryImpl(rootUri, childId, newPath, directoryDeferred)
|
||||
)
|
||||
exploreDirectoryImpl(rootUri, childId, newPath, directoryDeferred))
|
||||
} else {
|
||||
val size = cursor.getLong(sizeIndex)
|
||||
val childUri = DocumentsContract.buildDocumentUriUsingTree(rootUri, childId)
|
||||
|
@ -128,8 +126,7 @@ private class DeviceFSImpl(
|
|||
path = newPath,
|
||||
size = size,
|
||||
modifiedMs = lastModified,
|
||||
parent = directoryDeferred
|
||||
)
|
||||
parent = directoryDeferred)
|
||||
children.add(file)
|
||||
emit(file)
|
||||
}
|
||||
|
@ -146,7 +143,6 @@ private class DeviceFSImpl(
|
|||
DocumentsContract.Document.COLUMN_DISPLAY_NAME,
|
||||
DocumentsContract.Document.COLUMN_MIME_TYPE,
|
||||
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.filterIsInstance
|
||||
import kotlinx.coroutines.flow.fold
|
||||
import org.oxycblt.musikr.Interpretation
|
||||
import org.oxycblt.musikr.MutableLibrary
|
||||
import org.oxycblt.musikr.Storage
|
||||
|
|
|
@ -67,7 +67,9 @@ private class ExploreStepImpl(
|
|||
val addingMs = System.currentTimeMillis()
|
||||
return merge(
|
||||
deviceFS
|
||||
.explore(locations.asFlow(),)
|
||||
.explore(
|
||||
locations.asFlow(),
|
||||
)
|
||||
.filter { it.mimeType.startsWith("audio/") || it.mimeType == M3U.MIME_TYPE }
|
||||
.distribute(8)
|
||||
.distributedMap { file ->
|
||||
|
|
Loading…
Reference in a new issue