End transaction before handling db error.

This commit is contained in:
Greyson Parrelli
2023-05-15 21:14:29 -04:00
parent 02431c6ef4
commit 6a701591af
2 changed files with 9 additions and 1 deletions

View File

@@ -168,7 +168,9 @@ open class SignalDatabase(private val context: Application, databaseSecret: Data
db.version = newVersion
db.setTransactionSuccessful()
} finally {
db.endTransaction()
if (db.inTransaction()) {
db.endTransaction()
}
// We have to re-begin the transaction for the calling code (see comment at start of method)
db.beginTransaction()

View File

@@ -29,6 +29,12 @@ class SqlCipherErrorHandler(private val databaseName: String) : DatabaseErrorHan
if (result is DiagnosticResults.Success) {
if (result.pragma1Passes && result.pragma2Passes) {
var endCount = 0
while (db.inTransaction() && endCount < 10) {
db.endTransaction()
endCount++
}
attemptToClearFullTextSearchIndex()
throw DatabaseCorruptedError_BothChecksPass(lines)
} else if (!result.pragma1Passes && result.pragma2Passes) {