Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions bindings/matrix-sdk-ffi/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use matrix_sdk::{
authentication::oauth::{
AccountManagementActionFull, ClientId, OAuthAuthorizationData, OAuthSession,
},
event_cache::EventCacheError,
media::{MediaFormat, MediaRequestParameters, MediaRetentionPolicy, MediaThumbnailSettings},
ruma::{
api::client::{
Expand All @@ -39,7 +38,7 @@ use matrix_sdk::{
},
sliding_sync::Version as SdkSlidingSyncVersion,
store::RoomLoadSettings as SdkRoomLoadSettings,
Account, AuthApi, AuthSession, Client as MatrixClient, SessionChange, SessionTokens,
Account, AuthApi, AuthSession, Client as MatrixClient, Error, SessionChange, SessionTokens,
STATE_STORE_DATABASE_NAME,
};
use matrix_sdk_common::{stream::StreamExt, SendOutsideWasm, SyncOutsideWasm};
Expand Down Expand Up @@ -1510,8 +1509,8 @@ impl Client {
&self,
policy: MediaRetentionPolicy,
) -> Result<(), ClientError> {
let closure = async || -> Result<_, EventCacheError> {
let store = self.inner.event_cache_store().lock().await?;
let closure = async || -> Result<_, Error> {
let store = self.inner.media_store().lock().await?;
Ok(store.set_media_retention_policy(policy).await?)
};

Expand Down Expand Up @@ -1559,13 +1558,13 @@ impl Client {

// Clean up the media cache according to the current media retention policy.
self.inner
.event_cache_store()
.media_store()
.lock()
.await
.map_err(EventCacheError::from)?
.map_err(Error::from)?
.clean_up_media_cache()
.await
.map_err(EventCacheError::from)?;
.map_err(Error::from)?;

// Clear all the room chunks. It's important to *not* call
// `EventCacheStore::clear_all_linked_chunks` here, because there might be live
Expand Down
11 changes: 11 additions & 0 deletions crates/matrix-sdk-base/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use crate::{
deserialized_responses::DisplayName,
error::{Error, Result},
event_cache::store::EventCacheStoreLock,
media::store::MediaStoreLock,
response_processors::{self as processors, Context},
room::{
Room, RoomInfoNotableUpdate, RoomInfoNotableUpdateReasons, RoomMembersUpdate, RoomState,
Expand Down Expand Up @@ -91,6 +92,9 @@ pub struct BaseClient {
/// The store used by the event cache.
event_cache_store: EventCacheStoreLock,

/// The store used by the media cache.
media_store: MediaStoreLock,

/// The store used for encryption.
///
/// This field is only meant to be used for `OlmMachine` initialization.
Expand Down Expand Up @@ -189,6 +193,7 @@ impl BaseClient {
BaseClient {
state_store: store,
event_cache_store: config.event_cache_store,
media_store: config.media_store,
#[cfg(feature = "e2e-encryption")]
crypto_store: config.crypto_store,
#[cfg(feature = "e2e-encryption")]
Expand Down Expand Up @@ -222,6 +227,7 @@ impl BaseClient {
let copy = Self {
state_store: BaseStateStore::new(config.state_store),
event_cache_store: config.event_cache_store,
media_store: config.media_store,
// We copy the crypto store as well as the `OlmMachine` for two reasons:
// 1. The `self.crypto_store` is the same as the one used inside the `OlmMachine`.
// 2. We need to ensure that the parent and child use the same data and caches inside
Expand Down Expand Up @@ -306,6 +312,11 @@ impl BaseClient {
&self.event_cache_store
}

/// Get a reference to the media store.
pub fn media_store(&self) -> &MediaStoreLock {
&self.media_store
}

/// Check whether the client has been activated.
///
/// See [`BaseClient::activate`] to know what it means.
Expand Down
Loading