Fix possible crash during backup restore.
This commit is contained in:
parent
ba8ea3b54b
commit
ab9057cb25
1 changed files with 9 additions and 0 deletions
|
@ -1,9 +1,11 @@
|
|||
package org.thoughtcrime.securesms.jobs
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Data
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException
|
||||
import java.lang.Exception
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
@ -16,6 +18,8 @@ class OptimizeMessageSearchIndexJob private constructor(parameters: Parameters)
|
|||
companion object {
|
||||
const val KEY = "OptimizeMessageSearchIndexJob"
|
||||
|
||||
private val TAG = Log.tag(OptimizeMessageSearchIndexJob::class.java)
|
||||
|
||||
@JvmStatic
|
||||
fun enqueue() {
|
||||
ApplicationDependencies.getJobManager().add(OptimizeMessageSearchIndexJob())
|
||||
|
@ -37,6 +41,11 @@ class OptimizeMessageSearchIndexJob private constructor(parameters: Parameters)
|
|||
override fun getNextRunAttemptBackoff(pastAttemptCount: Int, exception: Exception): Long = 30.seconds.inWholeMilliseconds
|
||||
|
||||
override fun onRun() {
|
||||
if (!SignalStore.registrationValues().isRegistrationComplete || SignalStore.account().aci == null) {
|
||||
Log.w(TAG, "Registration not finished yet! Skipping.")
|
||||
return
|
||||
}
|
||||
|
||||
val success = SignalDatabase.messageSearch.optimizeIndex(5.seconds.inWholeMilliseconds)
|
||||
|
||||
if (!success) {
|
||||
|
|
Loading…
Add table
Reference in a new issue