mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 06:28:45 +03:00
Merge pull request #3584 from vector-im/feature/bca/fix_oom_spacechild
Fix / dm flattenParents always growing
This commit is contained in:
commit
7dc5d8490f
3 changed files with 19 additions and 4 deletions
1
changelog.d/3583.bugfix
Normal file
1
changelog.d/3583.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix crash out of memory
|
|
@ -19,9 +19,10 @@ package org.matrix.android.sdk.internal.database
|
||||||
import io.realm.DynamicRealm
|
import io.realm.DynamicRealm
|
||||||
import io.realm.FieldAttribute
|
import io.realm.FieldAttribute
|
||||||
import io.realm.RealmMigration
|
import io.realm.RealmMigration
|
||||||
import org.matrix.android.sdk.api.session.room.model.VersioningState
|
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomJoinRulesContent
|
import org.matrix.android.sdk.api.session.room.model.RoomJoinRulesContent
|
||||||
|
import org.matrix.android.sdk.api.session.room.model.VersioningState
|
||||||
import org.matrix.android.sdk.api.session.room.model.create.RoomCreateContent
|
import org.matrix.android.sdk.api.session.room.model.create.RoomCreateContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.tag.RoomTag
|
import org.matrix.android.sdk.api.session.room.model.tag.RoomTag
|
||||||
import org.matrix.android.sdk.internal.database.model.CurrentStateEventEntityFields
|
import org.matrix.android.sdk.internal.database.model.CurrentStateEventEntityFields
|
||||||
|
@ -40,13 +41,14 @@ import org.matrix.android.sdk.internal.database.model.SpaceChildSummaryEntityFie
|
||||||
import org.matrix.android.sdk.internal.database.model.SpaceParentSummaryEntityFields
|
import org.matrix.android.sdk.internal.database.model.SpaceParentSummaryEntityFields
|
||||||
import org.matrix.android.sdk.internal.database.model.TimelineEventEntityFields
|
import org.matrix.android.sdk.internal.database.model.TimelineEventEntityFields
|
||||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||||
|
import org.matrix.android.sdk.internal.query.process
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class RealmSessionStoreMigration @Inject constructor() : RealmMigration {
|
class RealmSessionStoreMigration @Inject constructor() : RealmMigration {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val SESSION_STORE_SCHEMA_VERSION = 14L
|
const val SESSION_STORE_SCHEMA_VERSION = 15L
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun migrate(realm: DynamicRealm, oldVersion: Long, newVersion: Long) {
|
override fun migrate(realm: DynamicRealm, oldVersion: Long, newVersion: Long) {
|
||||||
|
@ -66,6 +68,7 @@ class RealmSessionStoreMigration @Inject constructor() : RealmMigration {
|
||||||
if (oldVersion <= 11) migrateTo12(realm)
|
if (oldVersion <= 11) migrateTo12(realm)
|
||||||
if (oldVersion <= 12) migrateTo13(realm)
|
if (oldVersion <= 12) migrateTo13(realm)
|
||||||
if (oldVersion <= 13) migrateTo14(realm)
|
if (oldVersion <= 13) migrateTo14(realm)
|
||||||
|
if (oldVersion <= 14) migrateTo15(realm)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun migrateTo1(realm: DynamicRealm) {
|
private fun migrateTo1(realm: DynamicRealm) {
|
||||||
|
@ -306,4 +309,16 @@ class RealmSessionStoreMigration @Inject constructor() : RealmMigration {
|
||||||
|
|
||||||
roomAccountDataSchema.isEmbedded = true
|
roomAccountDataSchema.isEmbedded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun migrateTo15(realm: DynamicRealm) {
|
||||||
|
// fix issue with flattenParentIds on DM that kept growing with duplicate
|
||||||
|
// so we reset it, will be updated next sync
|
||||||
|
realm.where("RoomSummaryEntity")
|
||||||
|
.process(RoomSummaryEntityFields.MEMBERSHIP_STR, Membership.activeMemberships())
|
||||||
|
.equalTo(RoomSummaryEntityFields.IS_DIRECT, true)
|
||||||
|
.findAll()
|
||||||
|
.onEach {
|
||||||
|
it.setString(RoomSummaryEntityFields.FLATTEN_PARENT_IDS, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,6 @@ internal class RoomSummaryUpdater @Inject constructor(
|
||||||
measureTimeMillis {
|
measureTimeMillis {
|
||||||
val lookupMap = realm.where(RoomSummaryEntity::class.java)
|
val lookupMap = realm.where(RoomSummaryEntity::class.java)
|
||||||
.process(RoomSummaryEntityFields.MEMBERSHIP_STR, Membership.activeMemberships())
|
.process(RoomSummaryEntityFields.MEMBERSHIP_STR, Membership.activeMemberships())
|
||||||
.equalTo(RoomSummaryEntityFields.IS_DIRECT, false)
|
|
||||||
// we order by roomID to be consistent when breaking parent/child cycles
|
// we order by roomID to be consistent when breaking parent/child cycles
|
||||||
.sort(RoomSummaryEntityFields.ROOM_ID)
|
.sort(RoomSummaryEntityFields.ROOM_ID)
|
||||||
.findAll().map {
|
.findAll().map {
|
||||||
|
|
Loading…
Reference in a new issue