Commit 2cd3e613 authored by Geoffrey Métais's avatar Geoffrey Métais

Medialibrary parsing: prevent early service exit

parent 00a6a266
......@@ -78,6 +78,8 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope, Lifec
@Volatile
private var serviceLock = false
@Volatile
private var discoverTriggered = false
internal val sb = StringBuilder()
private val notificationActor by lazy {
......@@ -159,6 +161,7 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope, Lifec
exitCommand()
return
}
discoverTriggered = true
actions.offer(DiscoverStorage(path))
}
......@@ -313,6 +316,7 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope, Lifec
override fun onDiscoveryStarted(entryPoint: String) {
if (BuildConfig.DEBUG) Log.v(TAG, "onDiscoveryStarted: $entryPoint")
discoverTriggered = false
}
override fun onDiscoveryProgress(entryPoint: String) {
......@@ -343,7 +347,7 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope, Lifec
}
private fun exitCommand() = launch {
if (!medialibrary.isWorking && !serviceLock) {
if (!medialibrary.isWorking && !serviceLock && !discoverTriggered) {
lastNotificationTime = 0L
stopSelf()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment