From 00280ccb861eccd2fea5014e2bc950ac76651e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 25 Nov 2021 11:24:47 +0100 Subject: [PATCH] rust: Mark room keys that are imported from the backup as backed up --- rust-sdk/Cargo.toml | 4 ++-- rust-sdk/src/machine.rs | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/rust-sdk/Cargo.toml b/rust-sdk/Cargo.toml index bb4fadf147..9ee7b4bbf7 100644 --- a/rust-sdk/Cargo.toml +++ b/rust-sdk/Cargo.toml @@ -29,11 +29,11 @@ features = ["lax_deserialize"] [dependencies.matrix-sdk-common] git = "https://github.com/matrix-org/matrix-rust-sdk/" -rev = "2e4d5f25cba03bd26415b91defd6e762e8c31b63" +rev = "fc74526699b82ba5be3349e810ded51138dae7fc" [dependencies.matrix-sdk-crypto] git = "https://github.com/matrix-org/matrix-rust-sdk/" -rev = "2e4d5f25cba03bd26415b91defd6e762e8c31b63" +rev = "fc74526699b82ba5be3349e810ded51138dae7fc" features = ["sled_cryptostore", "qrcode", "backups_v1"] [dependencies.tokio] diff --git a/rust-sdk/src/machine.rs b/rust-sdk/src/machine.rs index c842334897..c7fa9741ab 100644 --- a/rust-sdk/src/machine.rs +++ b/rust-sdk/src/machine.rs @@ -616,6 +616,7 @@ impl OlmMachine { fn import_keys_helper( &self, keys: Vec, + from_backup: bool, progress_listener: Box, ) -> Result { let listener = |progress: usize, total: usize| { @@ -624,7 +625,7 @@ impl OlmMachine { let result = self .runtime - .block_on(self.inner.import_keys(keys, listener))?; + .block_on(self.inner.import_keys(keys, from_backup, listener))?; Ok(KeysImportResult { total: result.total_count as i64, @@ -650,14 +651,15 @@ impl OlmMachine { ) -> Result { let keys = Cursor::new(keys); let keys = decrypt_key_export(keys, passphrase)?; - self.import_keys_helper(keys, progress_listener) + self.import_keys_helper(keys, false, progress_listener) } /// Import room keys from the given serialized unencrypted key export. /// /// This method is the same as [`OlmMachine::import_keys`] but the /// decryption step is skipped and should be performed by the caller. This - /// may be useful for custom handling or for server-side key backups. + /// should be used if the room keys are comming from the server-side backup, + /// the method will mark all imported room keys as backed up. /// /// # Arguments /// @@ -678,7 +680,7 @@ impl OlmMachine { .filter_map(|k| k.ok()) .collect(); - self.import_keys_helper(keys, progress_listener) + self.import_keys_helper(keys, true, progress_listener) } /// Discard the currently active room key for the given room if there is