Add extra transaction protections.

This commit is contained in:
Greyson Parrelli 2024-09-12 14:44:09 -04:00 committed by Cody Henthorne
parent 0d37013481
commit 5c6644d1a1

View file

@ -17,12 +17,16 @@ inline fun <T : SupportSQLiteDatabase, R> T.withinTransaction(block: (T) -> R):
beginTransaction()
try {
val toReturn = block(this)
if (inTransaction()) {
setTransactionSuccessful()
}
return toReturn
} finally {
if (inTransaction()) {
endTransaction()
}
}
}
fun SupportSQLiteDatabase.getTableRowCount(table: String): Int {
return this.query("SELECT COUNT(*) FROM $table").use {