crypto: Fix the docs and return value of the import_keys method.
parent
17cc4fcb81
commit
404cc410cc
|
@ -1879,6 +1879,8 @@ impl Client {
|
|||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// This method will panic if it isn't run on a Tokio runtime.
|
||||
///
|
||||
/// This method will panic if it can't get enough randomness from the OS to
|
||||
/// encrypt the exported keys securely.
|
||||
///
|
||||
|
@ -1947,6 +1949,17 @@ impl Client {
|
|||
|
||||
/// Import E2EE keys from the given file path.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `path` - The file path where the exported key file will can be found.
|
||||
///
|
||||
/// * `passphrase` - The passphrase that should be used to decrypt the
|
||||
/// exported room keys.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// This method will panic if it isn't run on a Tokio runtime.
|
||||
///
|
||||
/// ```no_run
|
||||
/// # use std::{path::PathBuf, time::Duration};
|
||||
/// # use matrix_sdk::{
|
||||
|
@ -1972,7 +1985,7 @@ impl Client {
|
|||
feature = "docs",
|
||||
doc(cfg(all(encryption, not(target_arch = "wasm32"))))
|
||||
)]
|
||||
pub async fn import_keys(&self, path: PathBuf, passphrase: &str) -> Result<()> {
|
||||
pub async fn import_keys(&self, path: PathBuf, passphrase: &str) -> Result<usize> {
|
||||
let olm = self
|
||||
.base_client
|
||||
.olm_machine()
|
||||
|
@ -1988,9 +2001,7 @@ impl Client {
|
|||
let task = tokio::task::spawn_blocking(decrypt);
|
||||
let import = task.await.expect("Task join error").unwrap();
|
||||
|
||||
olm.import_keys(import).await.unwrap();
|
||||
|
||||
Ok(())
|
||||
Ok(olm.import_keys(import).await?)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -906,6 +906,7 @@ impl OlmMachine {
|
|||
// Only import the session if we didn't have this session or if it's
|
||||
// a better version of the same session, that is the first known
|
||||
// index is lower.
|
||||
// TODO load all sessions so we don't do a thousand small loads.
|
||||
if let Some(existing_session) = self
|
||||
.store
|
||||
.get_inbound_group_session(
|
||||
|
@ -929,6 +930,10 @@ impl OlmMachine {
|
|||
let num_sessions = sessions.len();
|
||||
|
||||
self.store.save_inbound_group_sessions(&sessions).await?;
|
||||
info!(
|
||||
"Successfully imported {} inbound group sessions",
|
||||
num_sessions
|
||||
);
|
||||
|
||||
Ok(num_sessions)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue