Improve reliability of rebuilding the search index.

This commit is contained in:
Greyson Parrelli
2024-09-05 09:59:29 -04:00
committed by Alex Hart
parent 6682815663
commit 1aed8eefcd
3 changed files with 57 additions and 35 deletions

View File

@@ -7,7 +7,6 @@ import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.jobmanager.impl.DataRestoreConstraint
import org.thoughtcrime.securesms.transport.RetryLaterException
import java.lang.Exception
import java.lang.IllegalStateException
import kotlin.time.Duration.Companion.seconds
class RebuildMessageSearchIndexJob private constructor(params: Parameters) : BaseJob(params) {
@@ -37,10 +36,11 @@ class RebuildMessageSearchIndexJob private constructor(params: Parameters) : Bas
override fun onFailure() = Unit
override fun onRun() {
try {
SignalDatabase.messageSearch.rebuildIndex()
} catch (e: IllegalStateException) {
throw RetryLaterException(e)
val success = SignalDatabase.messageSearch.rebuildIndex()
if (!success) {
Log.w(TAG, "Failed to rebuild search index. Resetting tables. That will enqueue another copy of this job as a side-effect.")
SignalDatabase.messageSearch.fullyResetTables()
}
}