Skip to content

Commit 12e39f5

Browse files
committed
chore(ffi): Restore ClientBuilder::session_paths as #[deprecated].
This method restores and marks `ClientBuilder::session_paths` as deprecated.
1 parent 38875b0 commit 12e39f5

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Allow UniFFI to use methods marked as `#[deprecated]`.
2+
#![allow(deprecated)]
3+
14
use std::{num::NonZeroUsize, sync::Arc, time::Duration};
25

36
#[cfg(not(target_family = "wasm"))]
@@ -526,6 +529,20 @@ impl ClientBuilder {
526529
builder.store = Some(StoreBuilder::Sqlite(unwrap_or_clone_arc(config)));
527530
Arc::new(builder)
528531
}
532+
533+
/// Sets the paths that the client will use to store its data and caches
534+
/// with SQLite.
535+
///
536+
/// Both paths **must** be unique per session as the SDK
537+
/// stores aren't capable of handling multiple users, however it is
538+
/// valid to use the same path for both stores on a single session.
539+
#[deprecated = "Use `ClientBuilder::session_store_with_sqlite` instead"]
540+
pub fn session_paths(self: Arc<Self>, data_path: String, cache_path: String) -> Arc<Self> {
541+
let mut builder = unwrap_or_clone_arc(self);
542+
builder.store =
543+
Some(StoreBuilder::Sqlite(store::SqliteStoreBuilder::raw_new(data_path, cache_path)));
544+
Arc::new(builder)
545+
}
529546
}
530547

531548
#[cfg(feature = "indexeddb")]

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ mod sqlite {
5656
system_is_memory_constrained: bool,
5757
}
5858

59+
impl SqliteStoreBuilder {
60+
pub(crate) fn raw_new(data_path: String, cache_path: String) -> Self {
61+
Self {
62+
paths: StorePaths { data_path, cache_path },
63+
passphrase: Zeroizing::new(None),
64+
pool_max_size: None,
65+
cache_size: None,
66+
journal_size_limit: None,
67+
system_is_memory_constrained: false,
68+
}
69+
}
70+
}
71+
5972
#[matrix_sdk_ffi_macros::export]
6073
impl SqliteStoreBuilder {
6174
/// Construct a [`SqliteStoreBuilder`] and set the paths that the client
@@ -66,14 +79,7 @@ mod sqlite {
6679
/// same path for both stores on a single session.
6780
#[uniffi::constructor]
6881
pub fn new(data_path: String, cache_path: String) -> Arc<Self> {
69-
Arc::new(Self {
70-
paths: SessionPaths { data_path, cache_path },
71-
passphrase: Zeroizing::new(None),
72-
pool_max_size: None,
73-
cache_size: None,
74-
journal_size_limit: None,
75-
system_is_memory_constrained: false,
76-
})
82+
Arc::new(Self::raw_new(data_path, cache_path))
7783
}
7884

7985
/// Set the passphrase for the stores.

0 commit comments

Comments
 (0)