File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed
bindings/matrix-sdk-ffi/src
matrix-sdk-base/src/event_cache/store
matrix-sdk/src/event_cache Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -1208,13 +1208,14 @@ impl Client {
1208
1208
/// retention policy.
1209
1209
pub async fn clear_caches ( & self ) -> Result < ( ) , ClientError > {
1210
1210
let closure = async || -> Result < _ , EventCacheError > {
1211
- let store = self . inner . event_cache_store ( ) . lock ( ) . await ?;
1212
-
1213
- // Clear all the room chunks.
1214
- store. clear_all_rooms_chunks ( ) . await ?;
1215
-
1216
1211
// Clean up the media cache according to the current media retention policy.
1217
- store. clean_up_media_cache ( ) . await ?;
1212
+ self . inner . event_cache_store ( ) . lock ( ) . await ?. clean_up_media_cache ( ) . await ?;
1213
+
1214
+ // Clear all the room chunks. It's important to *not* call
1215
+ // `EventCacheStore::clear_all_rooms_chunks` here, because there might be live
1216
+ // observers of the linked chunks, and that would cause some very bad state
1217
+ // mismatch.
1218
+ self . inner . event_cache ( ) . clear_all_rooms ( ) . await ?;
1218
1219
1219
1220
Ok ( ( ) )
1220
1221
} ;
Original file line number Diff line number Diff line change @@ -101,6 +101,10 @@ pub trait EventCacheStore: AsyncTraitDeps {
101
101
/// using the above [`Self::handle_linked_chunk_updates`] methods. It
102
102
/// must *also* delete all the events' content, if they were stored in a
103
103
/// separate table.
104
+ ///
105
+ /// ⚠ This is meant only for super specific use cases, where there shouldn't
106
+ /// be any live in-memory linked chunks. In general, prefer using
107
+ /// `EventCache::clear_all_rooms()` from the common SDK crate.
104
108
async fn clear_all_rooms_chunks ( & self ) -> Result < ( ) , Self :: Error > ;
105
109
106
110
/// Given a set of event IDs, return the duplicated events along with their
Original file line number Diff line number Diff line change @@ -361,6 +361,13 @@ impl EventCache {
361
361
Ok ( ( room, drop_handles) )
362
362
}
363
363
364
+ /// Cleanly clear all the rooms' event caches.
365
+ ///
366
+ /// This will notify any live observers that the room has been cleared.
367
+ pub async fn clear_all_rooms ( & self ) -> Result < ( ) > {
368
+ self . inner . clear_all_rooms ( ) . await
369
+ }
370
+
364
371
/// Add an initial set of events to the event cache, reloaded from a cache.
365
372
///
366
373
/// TODO: temporary for API compat, as the event cache should take care of
You can’t perform that action at this time.
0 commit comments