musikr: fix hidden files setting

This commit is contained in:
Alexander Capehart 2025-03-03 20:46:44 -07:00
parent 20a06ba2fb
commit 387a36a3f8
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
4 changed files with 9 additions and 8 deletions

View file

@ -57,5 +57,5 @@ data class Interpretation(
val separators: Separators,
/** Whether to ignore hidden files and directories (those starting with a dot). */
val ignoreHidden: Boolean = true
val ignoreHidden: Boolean
)

View file

@ -71,7 +71,7 @@ interface Musikr {
fun new(context: Context, storage: Storage, interpretation: Interpretation): Musikr =
MusikrImpl(
storage,
ExploreStep.from(context, storage),
ExploreStep.from(context, storage, interpretation),
ExtractStep.from(context, storage),
EvaluateStep.new(storage, interpretation))
}

View file

@ -31,16 +31,16 @@ import org.oxycblt.musikr.fs.MusicLocation
import org.oxycblt.musikr.fs.Path
internal interface DeviceFiles {
fun explore(locations: Flow<MusicLocation>, ignoreHidden: Boolean = true): Flow<DeviceNode>
fun explore(locations: Flow<MusicLocation>): Flow<DeviceNode>
companion object {
fun from(context: Context): DeviceFiles = DeviceFilesImpl(context.contentResolverSafe)
fun from(context: Context, ignoreHidden: Boolean): DeviceFiles = DeviceFilesImpl(context.contentResolverSafe, ignoreHidden)
}
}
@OptIn(ExperimentalCoroutinesApi::class)
private class DeviceFilesImpl(private val contentResolver: ContentResolver) : DeviceFiles {
override fun explore(locations: Flow<MusicLocation>, ignoreHidden: Boolean): Flow<DeviceNode> =
private class DeviceFilesImpl(private val contentResolver: ContentResolver, private val ignoreHidden: Boolean) : DeviceFiles {
override fun explore(locations: Flow<MusicLocation>): Flow<DeviceNode> =
locations.flatMapMerge { location ->
// Create a root directory for each location
val rootDirectory =

View file

@ -30,6 +30,7 @@ import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import org.oxycblt.musikr.Interpretation
import org.oxycblt.musikr.Storage
import org.oxycblt.musikr.fs.MusicLocation
import org.oxycblt.musikr.fs.device.DeviceDirectory
@ -44,8 +45,8 @@ internal interface ExploreStep {
fun explore(locations: List<MusicLocation>): Flow<ExploreNode>
companion object {
fun from(context: Context, storage: Storage): ExploreStep =
ExploreStepImpl(DeviceFiles.from(context), storage.storedPlaylists)
fun from(context: Context, storage: Storage, interpretation: Interpretation): ExploreStep =
ExploreStepImpl(DeviceFiles.from(context, interpretation.ignoreHidden), storage.storedPlaylists)
}
}