mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-19 06:04:31 -04:00
base: Swap around the store creation.
The state store creates directory structure but the crypto store does not. This can lead to confusing errors where we require a directory to be created by the library user but it gets created by the library.
This commit is contained in:
@@ -458,6 +458,20 @@ impl BaseClient {
|
||||
/// * `session` - An session that the user already has from a
|
||||
/// previous login call.
|
||||
pub async fn restore_login(&self, session: Session) -> Result<()> {
|
||||
// If there wasn't a state store opened, try to open the default one if
|
||||
// a store path was provided.
|
||||
if self.state_store.read().await.is_none() {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
if let Some(path) = &*self.store_path {
|
||||
let store = JsonStore::open(path)?;
|
||||
*self.state_store.write().await = Some(Box::new(store));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.sync_with_state_store(&session).await?;
|
||||
|
||||
#[cfg(feature = "encryption")]
|
||||
{
|
||||
let mut olm = self.olm.lock().await;
|
||||
@@ -496,20 +510,6 @@ impl BaseClient {
|
||||
}
|
||||
}
|
||||
|
||||
// If there wasn't a state store opened, try to open the default one if
|
||||
// a store path was provided.
|
||||
if self.state_store.read().await.is_none() {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
if let Some(path) = &*self.store_path {
|
||||
let store = JsonStore::open(path)?;
|
||||
*self.state_store.write().await = Some(Box::new(store));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.sync_with_state_store(&session).await?;
|
||||
|
||||
*self.session.write().await = Some(session);
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user