Make sure the live timeline is destroyed before clearing a room's cache (#4515)
* Make sure the live timeline is destroyed before clearing a room's cache According to the SDK team, having a live timeline could lead to DB issues. * Try to destroy all room and list item references when the `RustRoomFactory` is destroyed It may also have some effect on DB corruption issues we've seen
This commit is contained in:
parent
19c58489d0
commit
5d697711c0
2 changed files with 6 additions and 0 deletions
|
|
@ -311,6 +311,8 @@ class RoomListPresenter @Inject constructor(
|
||||||
|
|
||||||
private fun CoroutineScope.clearCacheOfRoom(roomId: RoomId) = launch {
|
private fun CoroutineScope.clearCacheOfRoom(roomId: RoomId) = launch {
|
||||||
client.getRoom(roomId)?.use { room ->
|
client.getRoom(roomId)?.use { room ->
|
||||||
|
// Ideally we wouldn't have a live timeline at this point, but right now we instantiate one when retrieving the room
|
||||||
|
room.liveTimeline.close()
|
||||||
room.clearEventCacheStorage()
|
room.clearEventCacheStorage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,10 @@ class RustRoomFactory(
|
||||||
withContext(NonCancellable + dispatcher) {
|
withContext(NonCancellable + dispatcher) {
|
||||||
mutex.withLock {
|
mutex.withLock {
|
||||||
Timber.d("Destroying room factory")
|
Timber.d("Destroying room factory")
|
||||||
|
cache.snapshot().values.forEach { (listItem, innerRoom) ->
|
||||||
|
innerRoom.destroy()
|
||||||
|
listItem.destroy()
|
||||||
|
}
|
||||||
cache.evictAll()
|
cache.evictAll()
|
||||||
isDestroyed = true
|
isDestroyed = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue