diff --git a/crates/common/src/manager/config.rs b/crates/common/src/manager/config.rs index 146f8444..ea30a64e 100644 --- a/crates/common/src/manager/config.rs +++ b/crates/common/src/manager/config.rs @@ -91,13 +91,13 @@ impl ConfigManager { &self, prefix: &str, strip_prefix: bool, - ) -> trc::Result> { + ) -> trc::Result> { let mut results = self.db_list(prefix, strip_prefix).await?; for (key, value) in self.cfg_local.load().iter() { if prefix.is_empty() || (!strip_prefix && key.starts_with(prefix)) { - results.push((key.clone(), value.clone())); + results.insert(key.clone(), value.clone()); } else if let Some(key) = key.strip_prefix(prefix) { - results.push((key.to_string(), value.clone())); + results.insert(key.to_string(), value.clone()); } } @@ -112,7 +112,7 @@ impl ConfigManager { let mut grouped = AHashMap::new(); let mut list = self.list(prefix, true).await?; - for (key, _) in &list { + for key in list.keys() { if let Some(key) = key.strip_suffix(suffix) { grouped.insert(key.to_string(), AHashMap::new()); } @@ -134,7 +134,7 @@ impl ConfigManager { &self, prefix: &str, strip_prefix: bool, - ) -> trc::Result> { + ) -> trc::Result> { let key = prefix.as_bytes(); let from_key = ValueKey::from(ValueClass::Config(key.to_vec())); let to_key = ValueKey::from(ValueClass::Config( @@ -143,7 +143,7 @@ impl ConfigManager { .chain([u8::MAX, u8::MAX, u8::MAX, u8::MAX, u8::MAX]) .collect::>(), )); - let mut results = Vec::new(); + let mut results = BTreeMap::new(); let patterns = self.cfg_local_patterns.clone(); self.cfg_store .iterate( @@ -158,7 +158,7 @@ impl ConfigManager { key = key.strip_prefix(prefix).unwrap_or(key); } - results.push((key.to_string(), String::deserialize(value)?)); + results.insert(key.to_string(), String::deserialize(value)?); } Ok(true) diff --git a/crates/jmap/src/api/management/settings.rs b/crates/jmap/src/api/management/settings.rs index 7acd0dfb..db0b6047 100644 --- a/crates/jmap/src/api/management/settings.rs +++ b/crates/jmap/src/api/management/settings.rs @@ -7,7 +7,7 @@ use hyper::Method; use serde_json::json; use store::ahash::AHashMap; -use utils::{config::ConfigKey, url_params::UrlParams}; +use utils::{config::ConfigKey, map::vec_map::VecMap, url_params::UrlParams}; use crate::{ api::{http::ToHttpResponse, HttpRequest, HttpResponse, JsonResponse}, @@ -75,7 +75,7 @@ impl JMAP { // Obtain record ids let mut total = 0; let mut ids = Vec::new(); - for (key, _) in &settings { + for key in settings.keys() { if let Some(id) = key.strip_suffix(&suffix) { if !id.is_empty() { if !has_filter { @@ -189,7 +189,7 @@ impl JMAP { .into_iter() .skip(offset) .take(if limit == 0 { total } else { limit }) - .collect::>(); + .collect::>(); Ok(JsonResponse::new(json!({ "data": {