From cd1da7348f795dcb7637c57a3b1b30b16c8e1231 Mon Sep 17 00:00:00 2001 From: ganfra Date: Mon, 20 Sep 2021 18:33:43 +0200 Subject: [PATCH] Timeline rework: make sure migration doesn't crash --- .../sdk/internal/database/RealmSessionStoreMigration.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt index e1d27647a6..5aa6914647 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionStoreMigration.kt @@ -344,7 +344,9 @@ internal object RealmSessionStoreMigration : RealmMigration { private fun migrateTo18(realm: DynamicRealm) { Timber.d("Step 17 -> 18") realm.schema.get("ChunkEntity")?.apply { - removeField("numberOfTimelineEvents") + if (hasField("numberOfTimelineEvents")) { + removeField("numberOfTimelineEvents") + } var cleanOldChunks = false if (!hasField(ChunkEntityFields.NEXT_CHUNK.`$`)) { cleanOldChunks = true