rust: Mark room keys that are imported from the backup as backed up
This commit is contained in:
parent
3f710ef4c0
commit
00280ccb86
@ -29,11 +29,11 @@ features = ["lax_deserialize"]
|
|||||||
|
|
||||||
[dependencies.matrix-sdk-common]
|
[dependencies.matrix-sdk-common]
|
||||||
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
||||||
rev = "2e4d5f25cba03bd26415b91defd6e762e8c31b63"
|
rev = "fc74526699b82ba5be3349e810ded51138dae7fc"
|
||||||
|
|
||||||
[dependencies.matrix-sdk-crypto]
|
[dependencies.matrix-sdk-crypto]
|
||||||
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
||||||
rev = "2e4d5f25cba03bd26415b91defd6e762e8c31b63"
|
rev = "fc74526699b82ba5be3349e810ded51138dae7fc"
|
||||||
features = ["sled_cryptostore", "qrcode", "backups_v1"]
|
features = ["sled_cryptostore", "qrcode", "backups_v1"]
|
||||||
|
|
||||||
[dependencies.tokio]
|
[dependencies.tokio]
|
||||||
|
@ -616,6 +616,7 @@ impl OlmMachine {
|
|||||||
fn import_keys_helper(
|
fn import_keys_helper(
|
||||||
&self,
|
&self,
|
||||||
keys: Vec<ExportedRoomKey>,
|
keys: Vec<ExportedRoomKey>,
|
||||||
|
from_backup: bool,
|
||||||
progress_listener: Box<dyn ProgressListener>,
|
progress_listener: Box<dyn ProgressListener>,
|
||||||
) -> Result<KeysImportResult, KeyImportError> {
|
) -> Result<KeysImportResult, KeyImportError> {
|
||||||
let listener = |progress: usize, total: usize| {
|
let listener = |progress: usize, total: usize| {
|
||||||
@ -624,7 +625,7 @@ impl OlmMachine {
|
|||||||
|
|
||||||
let result = self
|
let result = self
|
||||||
.runtime
|
.runtime
|
||||||
.block_on(self.inner.import_keys(keys, listener))?;
|
.block_on(self.inner.import_keys(keys, from_backup, listener))?;
|
||||||
|
|
||||||
Ok(KeysImportResult {
|
Ok(KeysImportResult {
|
||||||
total: result.total_count as i64,
|
total: result.total_count as i64,
|
||||||
@ -650,14 +651,15 @@ impl OlmMachine {
|
|||||||
) -> Result<KeysImportResult, KeyImportError> {
|
) -> Result<KeysImportResult, KeyImportError> {
|
||||||
let keys = Cursor::new(keys);
|
let keys = Cursor::new(keys);
|
||||||
let keys = decrypt_key_export(keys, passphrase)?;
|
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.
|
/// Import room keys from the given serialized unencrypted key export.
|
||||||
///
|
///
|
||||||
/// This method is the same as [`OlmMachine::import_keys`] but the
|
/// This method is the same as [`OlmMachine::import_keys`] but the
|
||||||
/// decryption step is skipped and should be performed by the caller. This
|
/// 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
|
/// # Arguments
|
||||||
///
|
///
|
||||||
@ -678,7 +680,7 @@ impl OlmMachine {
|
|||||||
.filter_map(|k| k.ok())
|
.filter_map(|k| k.ok())
|
||||||
.collect();
|
.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
|
/// Discard the currently active room key for the given room if there is
|
||||||
|
Loading…
Reference in New Issue
Block a user