crypto: Rewrite the device keys fetching in the SQLiteStore using filter_map.
parent
578c927e58
commit
a9d645cbcd
|
@ -472,23 +472,19 @@ impl SqliteStore {
|
|||
.fetch_all(&mut *connection)
|
||||
.await?;
|
||||
|
||||
let mut keys = BTreeMap::new();
|
||||
|
||||
for row in key_rows {
|
||||
let keys: BTreeMap<AlgorithmAndDeviceId, String> = key_rows
|
||||
.iter()
|
||||
.filter_map(|row| {
|
||||
let algorithm: &str = &row.0;
|
||||
let algorithm = if let Ok(a) = KeyAlgorithm::try_from(algorithm) {
|
||||
a
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let algorithm = KeyAlgorithm::try_from(algorithm).ok()?;
|
||||
let key = &row.1;
|
||||
|
||||
keys.insert(
|
||||
Some((
|
||||
AlgorithmAndDeviceId(algorithm, device_id.as_str().into()),
|
||||
key.to_owned(),
|
||||
);
|
||||
}
|
||||
))
|
||||
})
|
||||
.collect();
|
||||
|
||||
let device = Device::new(
|
||||
user_id,
|
||||
|
|
Loading…
Reference in New Issue