Merge hotfix 1.4.25 to develop

This commit is contained in:
Benoit Marty 2022-06-27 18:03:22 +02:00
commit 2f8aeb991e
3 changed files with 28 additions and 5 deletions

View File

@ -1,4 +1,18 @@
Changes in Element v1.4.24 (2022-06-21)
Changes in Element v1.4.25 (2022-06-27)
=======================================
Bugfixes 🐛
----------
- Second attempt to fix session database migration to version 30.
Changes in Element v1.4.24 (2022-06-22)
=======================================
Bugfixes 🐛
----------
- First attempt to fix session database migration to version 30.
Changes in Element v1.4.23 (2022-06-21)
=======================================
Bugfixes 🐛

View File

@ -0,0 +1,2 @@
Main changes in this version: Various bug fixes and stability improvements.
Full changelog: https://github.com/vector-im/element-android/releases

View File

@ -20,8 +20,8 @@ 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
import timber.log.Timber
/**
* Migrating to:
@ -35,16 +35,23 @@ internal class MigrateSessionTo030(realm: DynamicRealm) : RealmMigrator(realm, 3
.equalTo(ChunkEntityFields.IS_LAST_FORWARD, false)
.findAll()
val nbOfDeletedChunks = chunks.size
var nbOfDeletedTimelineEvents = 0
var nbOfDeletedEvents = 0
chunks.forEach { chunk ->
chunk.getList(ChunkEntityFields.TIMELINE_EVENTS.`$`).clearWith { timelineEvent ->
val timelineEvents = chunk.getList(ChunkEntityFields.TIMELINE_EVENTS.`$`)
timelineEvents.forEach { timelineEvent ->
// Don't delete state events
val event = timelineEvent.getObject(TimelineEventEntityFields.ROOT.`$`)
if (event?.isNull(EventEntityFields.STATE_KEY) == true) {
nbOfDeletedEvents++
event.deleteFromRealm()
timelineEvent.deleteFromRealm()
}
}
chunk.deleteFromRealm()
}
nbOfDeletedTimelineEvents += timelineEvents.size
timelineEvents.deleteAllFromRealm()
}
chunks.deleteAllFromRealm()
Timber.d("MigrateSessionTo030: $nbOfDeletedChunks deleted chunk(s), $nbOfDeletedTimelineEvents deleted TimelineEvent(s) and $nbOfDeletedEvents deleted Event(s).")
}
}