Attempt to address a search crash.

This commit is contained in:
Greyson Parrelli 2023-12-01 13:16:01 -05:00 committed by Cody Henthorne
parent 71b5645801
commit 098da3c3dd

View file

@ -1,10 +1,14 @@
package org.thoughtcrime.securesms.util;
import android.database.sqlite.SQLiteDatabaseCorruptException;
import androidx.annotation.NonNull;
import org.signal.core.util.ExceptionUtil;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.database.LogDatabase;
import org.thoughtcrime.securesms.database.SearchTable;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
@ -36,6 +40,15 @@ public class SignalUncaughtExceptionHandler implements Thread.UncaughtExceptionH
return;
}
if (e instanceof SQLiteDatabaseCorruptException) {
if (e.getMessage().indexOf("message_fts") >= 0) {
Log.w(TAG, "FTS corrupted! Resetting FTS index.");
SignalDatabase.messageSearch().fullyResetTables();
} else {
Log.w(TAG, "Some non-FTS related corruption?");
}
}
if (e instanceof OnErrorNotImplementedException && e.getCause() != null) {
e = e.getCause();
}