Fix beginTransaction crash when continuing a transaction

Change-Id: Ied0911c1f310ed59a5bf18e423efa5c8b146c668
This commit is contained in:
SpiritCroc 2022-04-14 13:56:26 +02:00
parent 23f4f72ba3
commit 0eca1e03c0
1 changed files with 3 additions and 1 deletions

View File

@ -38,7 +38,9 @@ internal fun <T> CoroutineScope.asyncTransaction(realmConfiguration: RealmConfig
suspend fun <T> awaitTransaction(config: RealmConfiguration, transaction: suspend (realm: Realm) -> T): T {
return withContext(Realm.WRITE_EXECUTOR.asCoroutineDispatcher()) {
Realm.getInstance(config).use { bgRealm ->
bgRealm.beginTransaction()
if (!bgRealm.isInTransaction) {
bgRealm.beginTransaction()
}
val result: T
try {
val start = System.currentTimeMillis()