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.master
parent
669a3f22d2
commit
11aa306de2
|
@ -458,6 +458,20 @@ impl BaseClient {
|
||||||
/// * `session` - An session that the user already has from a
|
/// * `session` - An session that the user already has from a
|
||||||
/// previous login call.
|
/// previous login call.
|
||||||
pub async fn restore_login(&self, session: Session) -> Result<()> {
|
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")]
|
#[cfg(feature = "encryption")]
|
||||||
{
|
{
|
||||||
let mut olm = self.olm.lock().await;
|
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);
|
*self.session.write().await = Some(session);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue