mirror of
https://github.com/element-hq/element-android
synced 2024-11-26 19:35:42 +03:00
Fix test crash
This commit is contained in:
parent
c52be1f5b1
commit
9680b044f9
2 changed files with 31 additions and 32 deletions
|
@ -152,7 +152,7 @@ class Rendezvous(
|
|||
|
||||
try {
|
||||
// explicitly download keys for ourself rather than racing with initial sync which might not complete in time
|
||||
awaitCallback<MXUsersDevicesMap<CryptoDeviceInfo>> { crypto.downloadKeys(listOf(userId), false, it) }
|
||||
crypto.downloadKeysIfNeeded(listOf(userId), false)
|
||||
} catch (e: Throwable) {
|
||||
// log as warning and continue as initial sync might still complete
|
||||
Timber.tag(TAG).w(e, "Failed to download keys for self")
|
||||
|
|
|
@ -146,38 +146,37 @@ internal class RealmCryptoStore @Inject constructor(
|
|||
.setWriteAsyncExecutor(monarchyWriteAsyncExecutor)
|
||||
.build()
|
||||
|
||||
// init {
|
||||
// // Ensure CryptoMetadataEntity is inserted in DB
|
||||
// doRealmTransaction(realmConfiguration) { realm ->
|
||||
// var currentMetadata = realm.where<CryptoMetadataEntity>().findFirst()
|
||||
//
|
||||
// var deleteAll = false
|
||||
//
|
||||
// if (currentMetadata != null) {
|
||||
// // Check credentials
|
||||
// // The device id may not have been provided in credentials.
|
||||
// // Check it only if provided, else trust the stored one.
|
||||
// if (currentMetadata.userId != userId ||
|
||||
// (deviceId != currentMetadata.deviceId)) {
|
||||
// Timber.w("## open() : Credentials do not match, close this store and delete data")
|
||||
// deleteAll = true
|
||||
// currentMetadata = null
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (currentMetadata == null) {
|
||||
// if (deleteAll) {
|
||||
// realm.deleteAll()
|
||||
// }
|
||||
//
|
||||
// // Metadata not found, or database cleaned, create it
|
||||
// realm.createObject(CryptoMetadataEntity::class.java, userId).apply {
|
||||
// deviceId = this@RealmCryptoStore.deviceId
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
init {
|
||||
// Ensure CryptoMetadataEntity is inserted in DB
|
||||
doRealmTransaction(realmConfiguration) { realm ->
|
||||
var currentMetadata = realm.where<CryptoMetadataEntity>().findFirst()
|
||||
|
||||
var deleteAll = false
|
||||
|
||||
if (currentMetadata != null) {
|
||||
// Check credentials
|
||||
// The device id may not have been provided in credentials.
|
||||
// Check it only if provided, else trust the stored one.
|
||||
if (currentMetadata.userId != userId ||
|
||||
(deviceId != null && deviceId != currentMetadata.deviceId)) {
|
||||
Timber.w("## open() : Credentials do not match, close this store and delete data")
|
||||
deleteAll = true
|
||||
currentMetadata = null
|
||||
}
|
||||
}
|
||||
|
||||
if (currentMetadata == null) {
|
||||
if (deleteAll) {
|
||||
realm.deleteAll()
|
||||
}
|
||||
|
||||
// Metadata not found, or database cleaned, create it
|
||||
realm.createObject(CryptoMetadataEntity::class.java, userId).apply {
|
||||
deviceId = this@RealmCryptoStore.deviceId
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* ==========================================================================================
|
||||
* Other data
|
||||
* ========================================================================================== */
|
||||
|
|
Loading…
Reference in a new issue