music: do not auto-index unless indeterminate
Make IndexerService only auto-index music when there is no library AND no loading has occured. This resolves an issue where if IndexerService dies after a failed index, IndexerService would try to index music regardless, as there was no library present.
This commit is contained in:
parent
f3a7813f5e
commit
dd00c70488
2 changed files with 9 additions and 3 deletions
|
@ -61,6 +61,13 @@ class Indexer {
|
||||||
private var currentGeneration = 0L
|
private var currentGeneration = 0L
|
||||||
private val callbacks = mutableListOf<Callback>()
|
private val callbacks = mutableListOf<Callback>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this instance is in an indeterminate state or not, where nothing has been previously
|
||||||
|
* loaded, yet no loading is going on.
|
||||||
|
*/
|
||||||
|
val isIndeterminate: Boolean
|
||||||
|
get() = lastResponse == null && loadingState == null
|
||||||
|
|
||||||
fun addCallback(callback: Callback) {
|
fun addCallback(callback: Callback) {
|
||||||
val currentState =
|
val currentState =
|
||||||
loadingState?.let { State.Loading(it) } ?: lastResponse?.let { State.Complete(it) }
|
loadingState?.let { State.Loading(it) } ?: lastResponse?.let { State.Complete(it) }
|
||||||
|
|
|
@ -62,10 +62,9 @@ class IndexerService : Service(), Indexer.Callback {
|
||||||
|
|
||||||
notification = IndexerNotification(this)
|
notification = IndexerNotification(this)
|
||||||
|
|
||||||
// FIXME: Do not re-index if Indexer has already completed
|
|
||||||
indexer.addCallback(this)
|
indexer.addCallback(this)
|
||||||
if (musicStore.library == null) {
|
if (musicStore.library == null && indexer.isIndeterminate) {
|
||||||
logD("No library present, loading music now")
|
logD("No library present and no previous response, loading music now")
|
||||||
onRequestReindex()
|
onRequestReindex()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue