Add extra transaction protections.
This commit is contained in:
parent
0d37013481
commit
5c6644d1a1
1 changed files with 6 additions and 2 deletions
|
@ -17,10 +17,14 @@ inline fun <T : SupportSQLiteDatabase, R> T.withinTransaction(block: (T) -> R):
|
|||
beginTransaction()
|
||||
try {
|
||||
val toReturn = block(this)
|
||||
setTransactionSuccessful()
|
||||
if (inTransaction()) {
|
||||
setTransactionSuccessful()
|
||||
}
|
||||
return toReturn
|
||||
} finally {
|
||||
endTransaction()
|
||||
if (inTransaction()) {
|
||||
endTransaction()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue