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