kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix possible crash during backup restore.
rodzic
ba8ea3b54b
commit
ab9057cb25
|
@ -1,9 +1,11 @@
|
||||||
package org.thoughtcrime.securesms.jobs
|
package org.thoughtcrime.securesms.jobs
|
||||||
|
|
||||||
|
import org.signal.core.util.logging.Log
|
||||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||||
import org.thoughtcrime.securesms.jobmanager.Data
|
import org.thoughtcrime.securesms.jobmanager.Data
|
||||||
import org.thoughtcrime.securesms.jobmanager.Job
|
import org.thoughtcrime.securesms.jobmanager.Job
|
||||||
|
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||||
import org.thoughtcrime.securesms.transport.RetryLaterException
|
import org.thoughtcrime.securesms.transport.RetryLaterException
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
import kotlin.time.Duration.Companion.seconds
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
@ -16,6 +18,8 @@ class OptimizeMessageSearchIndexJob private constructor(parameters: Parameters)
|
||||||
companion object {
|
companion object {
|
||||||
const val KEY = "OptimizeMessageSearchIndexJob"
|
const val KEY = "OptimizeMessageSearchIndexJob"
|
||||||
|
|
||||||
|
private val TAG = Log.tag(OptimizeMessageSearchIndexJob::class.java)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun enqueue() {
|
fun enqueue() {
|
||||||
ApplicationDependencies.getJobManager().add(OptimizeMessageSearchIndexJob())
|
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 getNextRunAttemptBackoff(pastAttemptCount: Int, exception: Exception): Long = 30.seconds.inWholeMilliseconds
|
||||||
|
|
||||||
override fun onRun() {
|
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)
|
val success = SignalDatabase.messageSearch.optimizeIndex(5.seconds.inWholeMilliseconds)
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
|
Ładowanie…
Reference in New Issue