From 8bea64bc0cbb1e2290302f623bd05b27b62042e9 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 22 Jun 2022 11:56:54 +0200 Subject: [PATCH] Fix migration to 30. Seems that `isNull` with long path is not working correctly. --- .../sdk/internal/database/migration/MigrateSessionTo030.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/migration/MigrateSessionTo030.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/migration/MigrateSessionTo030.kt index 3f7e2ef36a..f9c4a8b642 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/migration/MigrateSessionTo030.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/migration/MigrateSessionTo030.kt @@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.database.migration import io.realm.DynamicRealm import org.matrix.android.sdk.internal.database.model.ChunkEntityFields +import org.matrix.android.sdk.internal.database.model.EventEntityFields import org.matrix.android.sdk.internal.database.model.TimelineEventEntityFields import org.matrix.android.sdk.internal.extensions.clearWith import org.matrix.android.sdk.internal.util.database.RealmMigrator @@ -37,8 +38,9 @@ internal class MigrateSessionTo030(realm: DynamicRealm) : RealmMigrator(realm, 3 chunks.forEach { chunk -> chunk.getList(ChunkEntityFields.TIMELINE_EVENTS.`$`).clearWith { timelineEvent -> // Don't delete state events - if (timelineEvent.isNull(TimelineEventEntityFields.ROOT.STATE_KEY)) { - timelineEvent.getObject(TimelineEventEntityFields.ROOT.`$`)?.deleteFromRealm() + val event = timelineEvent.getObject(TimelineEventEntityFields.ROOT.`$`) + if (event?.isNull(EventEntityFields.STATE_KEY) == true) { + event.deleteFromRealm() timelineEvent.deleteFromRealm() } }