diff --git a/src/crypto/machine.rs b/src/crypto/machine.rs index e7e2f548..c451b85f 100644 --- a/src/crypto/machine.rs +++ b/src/crypto/machine.rs @@ -89,20 +89,21 @@ impl OlmMachine { path: P, passphrase: String, ) -> Result { + let mut store = + SqliteStore::open_with_passphrase(&user_id.to_string(), device_id, path, passphrase) + .await?; + + let account = match store.load_account().await? { + Some(a) => a, + None => Account::new(), + }; + Ok(OlmMachine { user_id: user_id.clone(), device_id: device_id.to_owned(), - account: Arc::new(Mutex::new(Account::new())), + account: Arc::new(Mutex::new(account)), uploaded_signed_key_count: None, - store: Box::new( - SqliteStore::open_with_passphrase( - &user_id.to_string(), - device_id, - path, - passphrase, - ) - .await?, - ), + store: Box::new(store), }) } diff --git a/src/crypto/store/sqlite.rs b/src/crypto/store/sqlite.rs index fca1093e..c1f27259 100644 --- a/src/crypto/store/sqlite.rs +++ b/src/crypto/store/sqlite.rs @@ -19,16 +19,6 @@ pub struct SqliteStore { pickle_passphrase: Option>, } -impl std::fmt::Debug for SqliteStore { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> StdResult<(), std::fmt::Error> { - write!( - fmt, - "SqliteStore {{ user_id: {}, device_id: {}, path: {:?} }}", - self.user_id, self.device_id, self.path - ) - } -} - static DATABASE_NAME: &str = "matrix-sdk-crypto.db"; impl SqliteStore { @@ -166,6 +156,16 @@ impl CryptoStore for SqliteStore { } } +impl std::fmt::Debug for SqliteStore { + fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> StdResult<(), std::fmt::Error> { + write!( + fmt, + "SqliteStore {{ user_id: {}, device_id: {}, path: {:?} }}", + self.user_id, self.device_id, self.path + ) + } +} + #[cfg(test)] mod test { use std::sync::Arc;