mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Periodically optimize the FTS index.
This commit is contained in:
@@ -115,9 +115,10 @@ public class ApplicationMigrations {
|
||||
static final int SMS_MMS_MERGE = 71;
|
||||
static final int REBUILD_MESSAGE_FTS_INDEX = 72;
|
||||
static final int UPDATE_SMS_JOBS = 73;
|
||||
static final int OPTIMIZE_MESSAGE_FTS_INDEX = 74;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 73;
|
||||
public static final int CURRENT_VERSION = 74;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
@@ -511,6 +512,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.UPDATE_SMS_JOBS, new UpdateSmsJobsMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.OPTIMIZE_MESSAGE_FTS_INDEX) {
|
||||
jobs.put(Version.OPTIMIZE_MESSAGE_FTS_INDEX, new OptimizeMessageSearchIndexMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.jobmanager.Data
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobs.OptimizeMessageSearchIndexJob
|
||||
|
||||
/**
|
||||
* Kicks off a job to optimize the message search index.
|
||||
*/
|
||||
internal class OptimizeMessageSearchIndexMigrationJob(
|
||||
parameters: Parameters = Parameters.Builder().build()
|
||||
) : MigrationJob(parameters) {
|
||||
|
||||
companion object {
|
||||
val TAG = Log.tag(OptimizeMessageSearchIndexMigrationJob::class.java)
|
||||
const val KEY = "OptimizeMessageSearchIndexMigrationJob"
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun performMigration() {
|
||||
OptimizeMessageSearchIndexJob.enqueue()
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<OptimizeMessageSearchIndexMigrationJob> {
|
||||
override fun create(parameters: Parameters, data: Data): OptimizeMessageSearchIndexMigrationJob {
|
||||
return OptimizeMessageSearchIndexMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user