Realm: fix realm instance close too soon
This commit is contained in:
parent
d0cb078f18
commit
948e24065f
@ -172,9 +172,6 @@ internal class RealmCryptoStore @Inject constructor(
|
||||
override fun close() {
|
||||
// Ensure no async request will be run later
|
||||
olmAccount?.releaseAccount()
|
||||
runBlocking {
|
||||
realmInstance.close()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateCryptoMetadata(operation: (CryptoMetadataEntity) -> Unit) {
|
||||
|
@ -26,7 +26,6 @@ import kotlinx.coroutines.withContext
|
||||
import org.matrix.android.sdk.R
|
||||
import org.matrix.android.sdk.api.util.Optional
|
||||
import org.matrix.android.sdk.internal.database.pagedlist.RealmTiledDataSource
|
||||
import timber.log.Timber
|
||||
|
||||
internal fun interface RealmQueryBuilder<T : RealmObject> {
|
||||
fun build(realm: TypedRealm): RealmQuery<T>
|
||||
@ -60,16 +59,12 @@ internal class RealmInstance(
|
||||
|
||||
suspend fun open() {
|
||||
coroutineScope.launch {
|
||||
realm.await()
|
||||
getRealm()
|
||||
}.join()
|
||||
}
|
||||
|
||||
suspend fun close() = withContext(NonCancellable) {
|
||||
try {
|
||||
realm.await().close()
|
||||
} catch (failure: Throwable) {
|
||||
Timber.e("Error whole closing realm. Instance was probably already closed.")
|
||||
}
|
||||
getRealm().close()
|
||||
}
|
||||
|
||||
fun <T : RealmObject> queryResults(
|
||||
|
Loading…
x
Reference in New Issue
Block a user