mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-05 14:35:20 -04:00
feat(ffi): add a method to clear all the non-critical caches of a client
This commit is contained in:
@@ -18,6 +18,7 @@ use matrix_sdk::{
|
||||
},
|
||||
OidcAuthorizationData, OidcSession,
|
||||
},
|
||||
event_cache::EventCacheError,
|
||||
media::{
|
||||
MediaFileHandle as SdkMediaFileHandle, MediaFormat, MediaRequestParameters,
|
||||
MediaThumbnailSettings,
|
||||
@@ -1159,6 +1160,28 @@ impl Client {
|
||||
let alias = RoomAliasId::parse(alias)?;
|
||||
self.inner.is_room_alias_available(&alias).await.map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Clear all the non-critical caches for this Client instance.
|
||||
///
|
||||
/// - This will empty all the room's persisted event caches, so all rooms
|
||||
/// will start as if they were empty.
|
||||
/// - This will empty the media cache according to the current media
|
||||
/// retention policy.
|
||||
pub async fn clear_caches(&self) -> Result<(), ClientError> {
|
||||
let closure = async || -> Result<_, EventCacheError> {
|
||||
let store = self.inner.event_cache_store().lock().await?;
|
||||
|
||||
// Clear all the room chunks.
|
||||
store.clear_all_rooms_chunks().await?;
|
||||
|
||||
// Clean up the media cache according to the current media retention policy.
|
||||
store.clean_up_media_cache().await?;
|
||||
|
||||
Ok(())
|
||||
};
|
||||
|
||||
Ok(closure().await?)
|
||||
}
|
||||
}
|
||||
|
||||
#[matrix_sdk_ffi_macros::export(callback_interface)]
|
||||
|
||||
Reference in New Issue
Block a user