Skip to content

Commit 91ef9a2

Browse files
dragonfly1033Shrey Patel
authored andcommitted
Merge pull request #5569 from matrix-org/dragonfly1033/split_media_db_2
Part 2 of Split media store from event cache store
2 parents 11fc140 + d441e70 commit 91ef9a2

File tree

44 files changed

+4104
-1923
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4104
-1923
lines changed

bindings/matrix-sdk-ffi/src/client.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use matrix_sdk::{
1414
authentication::oauth::{
1515
AccountManagementActionFull, ClientId, OAuthAuthorizationData, OAuthSession,
1616
},
17-
event_cache::EventCacheError,
1817
media::{MediaFormat, MediaRequestParameters, MediaRetentionPolicy, MediaThumbnailSettings},
1918
ruma::{
2019
api::client::{
@@ -39,7 +38,7 @@ use matrix_sdk::{
3938
},
4039
sliding_sync::Version as SdkSlidingSyncVersion,
4140
store::RoomLoadSettings as SdkRoomLoadSettings,
42-
Account, AuthApi, AuthSession, Client as MatrixClient, SessionChange, SessionTokens,
41+
Account, AuthApi, AuthSession, Client as MatrixClient, Error, SessionChange, SessionTokens,
4342
STATE_STORE_DATABASE_NAME,
4443
};
4544
use matrix_sdk_common::{stream::StreamExt, SendOutsideWasm, SyncOutsideWasm};
@@ -1510,8 +1509,8 @@ impl Client {
15101509
&self,
15111510
policy: MediaRetentionPolicy,
15121511
) -> Result<(), ClientError> {
1513-
let closure = async || -> Result<_, EventCacheError> {
1514-
let store = self.inner.event_cache_store().lock().await?;
1512+
let closure = async || -> Result<_, Error> {
1513+
let store = self.inner.media_store().lock().await?;
15151514
Ok(store.set_media_retention_policy(policy).await?)
15161515
};
15171516

@@ -1559,13 +1558,13 @@ impl Client {
15591558

15601559
// Clean up the media cache according to the current media retention policy.
15611560
self.inner
1562-
.event_cache_store()
1561+
.media_store()
15631562
.lock()
15641563
.await
1565-
.map_err(EventCacheError::from)?
1564+
.map_err(Error::from)?
15661565
.clean_up_media_cache()
15671566
.await
1568-
.map_err(EventCacheError::from)?;
1567+
.map_err(Error::from)?;
15691568

15701569
// Clear all the room chunks. It's important to *not* call
15711570
// `EventCacheStore::clear_all_linked_chunks` here, because there might be live

crates/matrix-sdk-base/src/client.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ use crate::{
5757
deserialized_responses::DisplayName,
5858
error::{Error, Result},
5959
event_cache::store::EventCacheStoreLock,
60+
media::store::MediaStoreLock,
6061
response_processors::{self as processors, Context},
6162
room::{
6263
Room, RoomInfoNotableUpdate, RoomInfoNotableUpdateReasons, RoomMembersUpdate, RoomState,
@@ -91,6 +92,9 @@ pub struct BaseClient {
9192
/// The store used by the event cache.
9293
event_cache_store: EventCacheStoreLock,
9394

95+
/// The store used by the media cache.
96+
media_store: MediaStoreLock,
97+
9498
/// The store used for encryption.
9599
///
96100
/// This field is only meant to be used for `OlmMachine` initialization.
@@ -189,6 +193,7 @@ impl BaseClient {
189193
BaseClient {
190194
state_store: store,
191195
event_cache_store: config.event_cache_store,
196+
media_store: config.media_store,
192197
#[cfg(feature = "e2e-encryption")]
193198
crypto_store: config.crypto_store,
194199
#[cfg(feature = "e2e-encryption")]
@@ -222,6 +227,7 @@ impl BaseClient {
222227
let copy = Self {
223228
state_store: BaseStateStore::new(config.state_store),
224229
event_cache_store: config.event_cache_store,
230+
media_store: config.media_store,
225231
// We copy the crypto store as well as the `OlmMachine` for two reasons:
226232
// 1. The `self.crypto_store` is the same as the one used inside the `OlmMachine`.
227233
// 2. We need to ensure that the parent and child use the same data and caches inside
@@ -306,6 +312,11 @@ impl BaseClient {
306312
&self.event_cache_store
307313
}
308314

315+
/// Get a reference to the media store.
316+
pub fn media_store(&self) -> &MediaStoreLock {
317+
&self.media_store
318+
}
319+
309320
/// Check whether the client has been activated.
310321
///
311322
/// See [`BaseClient::activate`] to know what it means.

0 commit comments

Comments
 (0)