music: fix testing artifacts in loading process

Fix testing lines created when working on the prior commit.
This commit is contained in:
Alexander Capehart 2023-06-23 08:49:08 -06:00
parent 036d952085
commit 19e8536323
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -23,8 +23,6 @@ import android.content.pm.PackageManager
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import java.util.LinkedList import java.util.LinkedList
import javax.inject.Inject import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -372,14 +370,16 @@ constructor(
// Do the initial query of the cache and media databases in parallel. // Do the initial query of the cache and media databases in parallel.
logD("Starting MediaStore query") logD("Starting MediaStore query")
val mediaStoreQueryJob = worker.scope.async { val mediaStoreQueryJob =
val query = try { worker.scope.async {
mediaStoreExtractor.query() val query =
} catch (e: Exception) { try {
return@async Result.failure(e) mediaStoreExtractor.query()
} catch (e: Exception) {
return@async Result.failure(e)
}
Result.success(query)
} }
Result.success(query)
}
val cache = val cache =
if (withCache) { if (withCache) {
logD("Reading cache") logD("Reading cache")
@ -424,12 +424,13 @@ constructor(
logD("Starting DeviceLibrary creation") logD("Starting DeviceLibrary creation")
val deviceLibraryJob = val deviceLibraryJob =
worker.scope.async(Dispatchers.Default) { worker.scope.async(Dispatchers.Default) {
val deviceLibrary = try { val deviceLibrary =
deviceLibraryFactory.create(completeSongs, processedSongs) try {
} catch (e: Exception) { deviceLibraryFactory.create(completeSongs, processedSongs)
processedSongs.close(e) } catch (e: Exception) {
return@async Result.failure(e) processedSongs.close(e)
} return@async Result.failure(e)
}
processedSongs.close() processedSongs.close()
Result.success(deviceLibrary) Result.success(deviceLibrary)
} }
@ -455,14 +456,16 @@ constructor(
logD("Discovered ${rawSongs.size} songs, starting finalization") logD("Discovered ${rawSongs.size} songs, starting finalization")
emitIndexingProgress(IndexingProgress.Indeterminate) emitIndexingProgress(IndexingProgress.Indeterminate)
logD("Starting UserLibrary query") logD("Starting UserLibrary query")
val userLibraryQueryJob = worker.scope.async { val userLibraryQueryJob =
val rawPlaylists = try { worker.scope.async {
userLibraryFactory.query() val rawPlaylists =
} catch (e: Exception) { try {
return@async Result.failure(e) userLibraryFactory.query()
} catch (e: Exception) {
return@async Result.failure(e)
}
Result.success(rawPlaylists)
} }
Result.success(rawPlaylists)
}
if (cache == null || cache.invalidated) { if (cache == null || cache.invalidated) {
logD("Writing cache [why=${cache?.invalidated}]") logD("Writing cache [why=${cache?.invalidated}]")
cacheRepository.writeCache(rawSongs) cacheRepository.writeCache(rawSongs)