Attempt to rebuild the FTS index in DB error handler.
This commit is contained in:
parent
54ecb0bb53
commit
123c282610
2 changed files with 18 additions and 10 deletions
|
@ -258,6 +258,14 @@ class SearchTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
|||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the FTS index.
|
||||
* Warning: This could be very expensive! (often seconds)
|
||||
*/
|
||||
fun rebuildIndex(db: SQLiteDatabase = writableDatabase.sqlCipherDatabase) {
|
||||
db.execSQL("INSERT INTO $FTS_TABLE_NAME($FTS_TABLE_NAME) VALUES('rebuild')")
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops all tables and recreates them.
|
||||
*/
|
||||
|
|
|
@ -165,16 +165,16 @@ class SqlCipherErrorHandler(private val application: Application, private val da
|
|||
}
|
||||
|
||||
private fun attemptToClearFullTextSearchIndex(db: SQLiteDatabase) {
|
||||
// try {
|
||||
// try {
|
||||
// db.reopenReadWrite()
|
||||
// } catch (e: Exception) {
|
||||
// Log.w(TAG, "Failed to re-open as read-write!", e)
|
||||
// }
|
||||
// SignalDatabase.messageSearch.fullyResetTables(db, useTransaction = false)
|
||||
// } catch (e: Throwable) {
|
||||
// Log.w(TAG, "Failed to clear full text search index.", e)
|
||||
// }
|
||||
try {
|
||||
try {
|
||||
db.reopenReadWrite()
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to re-open as read-write!", e)
|
||||
}
|
||||
SignalDatabase.messageSearch.rebuildIndex(db)
|
||||
} catch (e: Throwable) {
|
||||
Log.w(TAG, "Failed to rebuild the full text search index.", e)
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class DiagnosticResults(val logs: String) {
|
||||
|
|
Loading…
Add table
Reference in a new issue