diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/SearchTable.kt b/app/src/main/java/org/thoughtcrime/securesms/database/SearchTable.kt index f3c3a45de9..017240e4c0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/SearchTable.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/SearchTable.kt @@ -160,39 +160,25 @@ class SearchTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa /** * Re-adds every message to the index. It's fine to insert the same message twice; the table will naturally de-dupe. * - * In order to prevent the database from locking up with super large inserts, this will perform the re-index in batches of the size you specify. - * It is not guaranteed that every batch will be the same size, but rather that the batches will be _no larger_ than the specified size. - * * Warning: This is a potentially extremely-costly operation! It can take 10+ seconds on large installs and/or slow devices. * Be smart about where you call this. * * @return True if the rebuild was successful, otherwise false. */ - fun rebuildIndex(batchSize: Long = 10_000L): Boolean { + fun rebuildIndex(): Boolean { try { - val maxId: Long = SignalDatabase.messages.getNextId() - - Log.i(TAG, "Re-indexing. Operating on ID's 1-$maxId in steps of $batchSize.") - - for (i in 1..maxId step batchSize) { - Log.i(TAG, "Reindexing ID's [$i, ${i + batchSize})") - - writableDatabase.withinTransaction { db -> - db.execSQL( - """ - INSERT INTO $FTS_TABLE_NAME ($ID, $BODY, $THREAD_ID) - SELECT - ${MessageTable.ID}, - ${MessageTable.BODY}, - ${MessageTable.THREAD_ID} - FROM - ${MessageTable.TABLE_NAME} - WHERE - ${MessageTable.ID} >= $i AND - ${MessageTable.ID} < ${i + batchSize} - """ - ) - } + writableDatabase.withinTransaction { db -> + db.execSQL( + """ + INSERT INTO $FTS_TABLE_NAME ($ID, $BODY, $THREAD_ID) + SELECT + ${MessageTable.ID}, + ${MessageTable.BODY}, + ${MessageTable.THREAD_ID} + FROM + ${MessageTable.TABLE_NAME} + """ + ) } } catch (e: SQLiteException) { Log.w(TAG, "Failed to rebuild index!", e) diff --git a/app/src/main/java/org/thoughtcrime/securesms/migrations/RebuildMessageSearchIndexMigrationJob.kt b/app/src/main/java/org/thoughtcrime/securesms/migrations/RebuildMessageSearchIndexMigrationJob.kt index 5277133519..63c992b859 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/migrations/RebuildMessageSearchIndexMigrationJob.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/migrations/RebuildMessageSearchIndexMigrationJob.kt @@ -7,6 +7,7 @@ import org.thoughtcrime.securesms.jobmanager.Job /** * Rebuilds the full-text search index for the messages table. */ +@Deprecated("Do not use! Perform the index rebuild synchronously instead.") internal class RebuildMessageSearchIndexMigrationJob( parameters: Parameters = Parameters.Builder().build() ) : MigrationJob(parameters) {