Skip to content

Commit

Permalink
run ktlintFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
anilbeesetti committed Aug 13, 2024
1 parent 8bbee10 commit 3cdc151
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -398,5 +398,5 @@ suspend fun ContentResolver.deleteMedia(
}
}

fun Context.getVolumeDirs() = getExternalFilesDirs(null)
fun Context.getStorageVolumes() = getExternalFilesDirs(null)
.map { File(it.path.substringBefore("/Android")) }
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.anilbeesetti.nextplayer.core.domain

import android.os.Environment
import dev.anilbeesetti.nextplayer.core.common.Dispatcher
import dev.anilbeesetti.nextplayer.core.common.NextDispatchers
import dev.anilbeesetti.nextplayer.core.data.repository.MediaRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import dev.anilbeesetti.nextplayer.core.common.Dispatcher
import dev.anilbeesetti.nextplayer.core.common.NextDispatchers
import dev.anilbeesetti.nextplayer.core.common.di.ApplicationScope
import dev.anilbeesetti.nextplayer.core.common.extensions.VIDEO_COLLECTION_URI
import dev.anilbeesetti.nextplayer.core.common.extensions.getVolumeDirs
import dev.anilbeesetti.nextplayer.core.common.extensions.getStorageVolumes
import dev.anilbeesetti.nextplayer.core.common.extensions.prettyName
import dev.anilbeesetti.nextplayer.core.common.extensions.scanPaths
import dev.anilbeesetti.nextplayer.core.common.extensions.scanStorage
Expand Down Expand Up @@ -50,7 +50,7 @@ class LocalMediaSynchronizer @Inject constructor(

override suspend fun refresh(path: String?): Boolean {
return path?.let { context.scanPaths(listOf(path)) }
?: context.getVolumeDirs().all { context.scanStorage(it.path) }
?: context.getStorageVolumes().all { context.scanStorage(it.path) }
}

override fun startSync() {
Expand All @@ -67,12 +67,9 @@ class LocalMediaSynchronizer @Inject constructor(

private suspend fun updateDirectories(media: List<MediaVideo>) =
withContext(Dispatchers.Default) {
val directories = context.getVolumeDirs().flatMap {
getDirectoryEntities(
currentFolder = it,
media = media
)
}
val directories = context.getStorageVolumes().flatMap {
getDirectoryEntities(currentFolder = it, media = media)
}
directoryDao.upsertAll(directories)

val currentDirectoryPaths = directories.map { it.path }
Expand Down

0 comments on commit 3cdc151

Please sign in to comment.