Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions core/crates/sync/src/keys/account_replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,7 @@ impl KeyService {
};
let mut txn = self.begin().await?;
let own = self.rotating_account(txn.as_mut()).await?;
let mut keep_ids: Vec<KeyDeviceId> = Vec::new();
for key_device in keep {
if *key_device != own.device.key_device && !keep_ids.contains(key_device) {
keep_ids.push(*key_device);
}
}
keep_ids.sort();
let keep_ids = kept_others(keep, own.device.key_device);
if held.is_none()
&& keep_ids
.iter()
Expand Down Expand Up @@ -549,6 +543,14 @@ impl KeyService {
}
}

// The other devices a replace keeps, once each and in order, so a retry compares equal to what was built.
fn kept_others(keep: &[KeyDeviceId], own: KeyDeviceId) -> Vec<KeyDeviceId> {
let mut ids: Vec<KeyDeviceId> = keep.iter().copied().filter(|device| *device != own).collect();
ids.sort();
ids.dedup();
ids
}

fn account_device(key_device: KeyDeviceId, this_device: bool, device: Option<DeviceRowId>) -> AccountDevice {
AccountDevice {
key_device,
Expand Down
Loading