diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/RebuildMessageSearchIndexJob.kt b/app/src/main/java/org/thoughtcrime/securesms/jobs/RebuildMessageSearchIndexJob.kt index 06cec35de3..766885d50a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/RebuildMessageSearchIndexJob.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/RebuildMessageSearchIndexJob.kt @@ -5,6 +5,8 @@ import org.thoughtcrime.securesms.database.SignalDatabase import org.thoughtcrime.securesms.dependencies.ApplicationDependencies import org.thoughtcrime.securesms.jobmanager.Job import java.lang.Exception +import java.lang.IllegalStateException +import kotlin.time.Duration.Companion.seconds class RebuildMessageSearchIndexJob private constructor(params: Parameters) : BaseJob(params) { @@ -21,6 +23,7 @@ class RebuildMessageSearchIndexJob private constructor(params: Parameters) : Bas private constructor() : this( Parameters.Builder() .setQueue("RebuildMessageSearchIndex") + .setMaxAttempts(3) .build() ) @@ -34,7 +37,11 @@ class RebuildMessageSearchIndexJob private constructor(params: Parameters) : Bas SignalDatabase.messageSearch.rebuildIndex() } - override fun onShouldRetry(e: Exception): Boolean = false + override fun getNextRunAttemptBackoff(pastAttemptCount: Int, exception: Exception): Long { + return 10.seconds.inWholeMilliseconds + } + + override fun onShouldRetry(e: Exception): Boolean = e is IllegalStateException class Factory : Job.Factory { override fun create(parameters: Parameters, serializedData: ByteArray?): RebuildMessageSearchIndexJob { diff --git a/app/src/main/java/org/thoughtcrime/securesms/migrations/ApplicationMigrations.java b/app/src/main/java/org/thoughtcrime/securesms/migrations/ApplicationMigrations.java index 8475d57f63..45a3cf0dae 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/migrations/ApplicationMigrations.java +++ b/app/src/main/java/org/thoughtcrime/securesms/migrations/ApplicationMigrations.java @@ -123,9 +123,10 @@ public class ApplicationMigrations { static final int SYSTEM_NAME_RESYNC = 78; static final int RECOVERY_PASSWORD_SYNC = 79; static final int DECRYPTIONS_DRAINED = 80; + static final int REBUILD_MESSAGE_FTS_INDEX_3 = 81; } - public static final int CURRENT_VERSION = 80; + public static final int CURRENT_VERSION = 81; /** * This *must* be called after the {@link JobManager} has been instantiated, but *before* the call @@ -547,6 +548,10 @@ public class ApplicationMigrations { jobs.put(Version.DECRYPTIONS_DRAINED, new DecryptionsDrainedMigrationJob()); } + if (lastSeenVersion < Version.REBUILD_MESSAGE_FTS_INDEX_3) { + jobs.put(Version.REBUILD_MESSAGE_FTS_INDEX_3, new RebuildMessageSearchIndexMigrationJob()); + } + return jobs; }