Fix test crash
This commit is contained in:
parent
c52be1f5b1
commit
9680b044f9
@ -152,7 +152,7 @@ class Rendezvous(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// explicitly download keys for ourself rather than racing with initial sync which might not complete in time
|
// 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) {
|
} catch (e: Throwable) {
|
||||||
// log as warning and continue as initial sync might still complete
|
// log as warning and continue as initial sync might still complete
|
||||||
Timber.tag(TAG).w(e, "Failed to download keys for self")
|
Timber.tag(TAG).w(e, "Failed to download keys for self")
|
||||||
|
@ -146,38 +146,37 @@ internal class RealmCryptoStore @Inject constructor(
|
|||||||
.setWriteAsyncExecutor(monarchyWriteAsyncExecutor)
|
.setWriteAsyncExecutor(monarchyWriteAsyncExecutor)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
// init {
|
init {
|
||||||
// // Ensure CryptoMetadataEntity is inserted in DB
|
// Ensure CryptoMetadataEntity is inserted in DB
|
||||||
// doRealmTransaction(realmConfiguration) { realm ->
|
doRealmTransaction(realmConfiguration) { realm ->
|
||||||
// var currentMetadata = realm.where<CryptoMetadataEntity>().findFirst()
|
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
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
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
|
* Other data
|
||||||
* ========================================================================================== */
|
* ========================================================================================== */
|
||||||
|
Loading…
Reference in New Issue
Block a user