mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Fix / protect against crash during migration
This commit is contained in:
parent
024c62515c
commit
a995615f87
1 changed files with 35 additions and 29 deletions
|
@ -102,6 +102,7 @@ internal object RealmCryptoStoreMigration : RealmMigration {
|
||||||
?.addRealmObjectField(DeviceInfoEntityFields.TRUST_LEVEL_ENTITY.`$`, trustLevelentityEntitySchema)
|
?.addRealmObjectField(DeviceInfoEntityFields.TRUST_LEVEL_ENTITY.`$`, trustLevelentityEntitySchema)
|
||||||
?.transform { obj ->
|
?.transform { obj ->
|
||||||
|
|
||||||
|
try {
|
||||||
val oldSerializedData = obj.getString("deviceInfoData")
|
val oldSerializedData = obj.getString("deviceInfoData")
|
||||||
deserializeFromRealm<MXDeviceInfo>(oldSerializedData)?.let { oldDevice ->
|
deserializeFromRealm<MXDeviceInfo>(oldSerializedData)?.let { oldDevice ->
|
||||||
|
|
||||||
|
@ -135,6 +136,11 @@ internal object RealmCryptoStoreMigration : RealmMigration {
|
||||||
obj.setString(DeviceInfoEntityFields.SIGNATURE_MAP_JSON, mapMigrationAdapter.toJson(oldDevice.signatures))
|
obj.setString(DeviceInfoEntityFields.SIGNATURE_MAP_JSON, mapMigrationAdapter.toJson(oldDevice.signatures))
|
||||||
obj.setString(DeviceInfoEntityFields.UNSIGNED_MAP_JSON, mapMigrationAdapter.toJson(oldDevice.unsigned))
|
obj.setString(DeviceInfoEntityFields.UNSIGNED_MAP_JSON, mapMigrationAdapter.toJson(oldDevice.unsigned))
|
||||||
}
|
}
|
||||||
|
} catch (failure: Throwable) {
|
||||||
|
Timber.w(failure, "Crypto Data base migration error")
|
||||||
|
// an unfortunate refactor did modify that class, making deserialization failing
|
||||||
|
// so we just skip and ignore..
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?.removeField("deviceInfoData")
|
?.removeField("deviceInfoData")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue