Switch the FFI bindings to use the SQLite cryptostore

This commit is contained in:
Damir Jelić 2023-03-29 11:44:33 +02:00 committed by GitHub
parent d680b331d0
commit 03aba95e1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 3 deletions

2
Cargo.lock generated
View File

@ -2978,6 +2978,8 @@ dependencies = [
"futures-util", "futures-util",
"log-panics", "log-panics",
"matrix-sdk", "matrix-sdk",
"matrix-sdk-sled",
"matrix-sdk-sqlite",
"mime", "mime",
"once_cell", "once_cell",
"opentelemetry", "opentelemetry",

View File

@ -23,6 +23,8 @@ eyeball-im = { workspace = true }
extension-trait = "1.0.1" extension-trait = "1.0.1"
futures-core = "0.3.17" futures-core = "0.3.17"
futures-util = { version = "0.3.17", default-features = false } futures-util = { version = "0.3.17", default-features = false }
matrix-sdk-sqlite = { path = "../../crates/matrix-sdk-sqlite", features = ["crypto-store"] }
matrix-sdk-sled = { path = "../../crates/matrix-sdk-sled" }
mime = "0.3.16" mime = "0.3.16"
# FIXME: we currently can't feature flag anything in the api.udl, therefore we must enforce experimental-sliding-sync being exposed here.. # FIXME: we currently can't feature flag anything in the api.udl, therefore we must enforce experimental-sliding-sync being exposed here..
# see https://github.com/matrix-org/matrix-rust-sdk/issues/1014 # see https://github.com/matrix-org/matrix-rust-sdk/issues/1014
@ -59,7 +61,6 @@ features = [
"experimental-timeline", "experimental-timeline",
"e2e-encryption", "e2e-encryption",
"markdown", "markdown",
"sled",
"socks", "socks",
"rustls-tls", "rustls-tls",
] ]
@ -74,6 +75,5 @@ features = [
"e2e-encryption", "e2e-encryption",
"markdown", "markdown",
"native-tls", "native-tls",
"sled",
"socks", "socks",
] ]

View File

@ -2,6 +2,7 @@ use std::{fs, path::PathBuf, sync::Arc};
use anyhow::anyhow; use anyhow::anyhow;
use matrix_sdk::{ use matrix_sdk::{
config::StoreConfig,
ruma::{ ruma::{
api::{error::UnknownVersionError, MatrixVersion}, api::{error::UnknownVersionError, MatrixVersion},
ServerName, UserId, ServerName, UserId,
@ -102,7 +103,24 @@ impl ClientBuilder {
let data_path = PathBuf::from(base_path).join(sanitize(username)); let data_path = PathBuf::from(base_path).join(sanitize(username));
fs::create_dir_all(&data_path)?; fs::create_dir_all(&data_path)?;
inner_builder = inner_builder.sled_store(data_path, builder.passphrase.as_deref()); let mut state_store =
matrix_sdk_sled::SledStateStore::builder().path(data_path.to_owned());
if let Some(passphrase) = builder.passphrase.as_deref() {
state_store = state_store.passphrase(passphrase.to_owned());
}
let state_store = state_store.build()?;
let crypto_store = RUNTIME.block_on(matrix_sdk_sqlite::SqliteCryptoStore::open(
&data_path,
builder.passphrase.as_deref(),
))?;
let store_config =
StoreConfig::new().state_store(state_store).crypto_store(crypto_store);
inner_builder = inner_builder.store_config(store_config)
} }
// Determine server either from URL, server name or user ID. // Determine server either from URL, server name or user ID.