diff --git a/crates/imap-proto/src/parser/uidbatches.rs b/crates/imap-proto/src/parser/uidbatches.rs index 2f781e1f..3d5f1618 100644 --- a/crates/imap-proto/src/parser/uidbatches.rs +++ b/crates/imap-proto/src/parser/uidbatches.rs @@ -42,9 +42,9 @@ impl Request { "Expected a batch range in the form 'from:to'.", ) })?; - let from = parse_number::(from.as_bytes()) + let from = parse_number::(from.trim().as_bytes()) .map_err(|v| bad(self.tag.to_compact_string(), v))?; - let to = parse_number::(to.as_bytes()) + let to = parse_number::(to.trim().as_bytes()) .map_err(|v| bad(self.tag.to_compact_string(), v))?; if from == 0 || to == 0 { diff --git a/crates/imap/src/op/copy_move.rs b/crates/imap/src/op/copy_move.rs index 198fd784..97de5c2c 100644 --- a/crates/imap/src/op/copy_move.rs +++ b/crates/imap/src/op/copy_move.rs @@ -203,8 +203,7 @@ impl SessionData { if ids.len() > message_limit { let mut uids = ids.values().map(|imap_id| imap_id.uid).collect::>(); let cutoff = uids.len() - message_limit; - uids.select_nth_unstable(cutoff); - let lowest_uid = uids[cutoff]; + let lowest_uid = *uids.select_nth_unstable(cutoff).1; if !is_move { return self diff --git a/crates/imap/src/op/expunge.rs b/crates/imap/src/op/expunge.rs index 6889d2d5..80133b94 100644 --- a/crates/imap/src/op/expunge.rs +++ b/crates/imap/src/op/expunge.rs @@ -170,9 +170,9 @@ impl SessionData { if uids.len() > message_limit as usize { let cutoff = uids.len() - message_limit as usize; - uids.select_nth_unstable(cutoff); - limited_uid = Some(uids[cutoff].0); - for (_, id) in &uids[..cutoff] { + let (below, lowest, _) = uids.select_nth_unstable(cutoff); + limited_uid = Some(lowest.0); + for (_, id) in below { deleted_ids.remove(*id); } } diff --git a/crates/imap/src/op/store.rs b/crates/imap/src/op/store.rs index 5b5e76c8..8a33843e 100644 --- a/crates/imap/src/op/store.rs +++ b/crates/imap/src/op/store.rs @@ -222,8 +222,7 @@ impl SessionData { if ids.len() > message_limit { let mut uids = ids.values().map(|imap_id| imap_id.uid).collect::>(); let cutoff = uids.len() - message_limit; - uids.select_nth_unstable(cutoff); - let lowest_uid = uids[cutoff]; + let lowest_uid = *uids.select_nth_unstable(cutoff).1; ids.retain(|_, imap_id| imap_id.uid >= lowest_uid); let code = ResponseCode::MessageLimit { diff --git a/crates/imap/src/op/uidbatches.rs b/crates/imap/src/op/uidbatches.rs index 5ff8ab9d..f80245b0 100644 --- a/crates/imap/src/op/uidbatches.rs +++ b/crates/imap/src/op/uidbatches.rs @@ -97,10 +97,11 @@ impl Session { } trc::event!( - Imap(trc::ImapEvent::Search), + Imap(trc::ImapEvent::UidBatches), SpanId = self.session_id, AccountId = mailbox.id.account_id, MailboxId = mailbox.id.mailbox_id, + Limit = arguments.batch_size, Total = ranges.len(), Elapsed = op_start.elapsed() ); diff --git a/crates/trc/src/event/enums.rs b/crates/trc/src/event/enums.rs index 18f8b70f..6a93b5f7 100644 --- a/crates/trc/src/event/enums.rs +++ b/crates/trc/src/event/enums.rs @@ -6,7 +6,7 @@ // This file is auto-generated. Do not edit directly. -pub const TOTAL_EVENT_COUNT: usize = 634; +pub const TOTAL_EVENT_COUNT: usize = 635; pub const TOTAL_METRIC_COUNT: usize = 367; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -335,6 +335,7 @@ pub enum ImapEvent { Subscribe = 192, Unsubscribe = 194, Thread = 193, + UidBatches = 634, GetQuota = 57, Error = 168, RawInput = 183, diff --git a/crates/trc/src/event/enums_impl.rs b/crates/trc/src/event/enums_impl.rs index 0ec0007f..44ee2ee9 100644 --- a/crates/trc/src/event/enums_impl.rs +++ b/crates/trc/src/event/enums_impl.rs @@ -225,6 +225,7 @@ impl EventType { b"imap.subscribe" => EventType::Imap(ImapEvent::Subscribe), b"imap.unsubscribe" => EventType::Imap(ImapEvent::Unsubscribe), b"imap.thread" => EventType::Imap(ImapEvent::Thread), + b"imap.uid-batches" => EventType::Imap(ImapEvent::UidBatches), b"imap.get-quota" => EventType::Imap(ImapEvent::GetQuota), b"imap.error" => EventType::Imap(ImapEvent::Error), b"imap.raw-input" => EventType::Imap(ImapEvent::RawInput), @@ -887,6 +888,7 @@ impl EventType { EventType::Imap(ImapEvent::Subscribe) => "imap.subscribe", EventType::Imap(ImapEvent::Unsubscribe) => "imap.unsubscribe", EventType::Imap(ImapEvent::Thread) => "imap.thread", + EventType::Imap(ImapEvent::UidBatches) => "imap.uid-batches", EventType::Imap(ImapEvent::GetQuota) => "imap.get-quota", EventType::Imap(ImapEvent::Error) => "imap.error", EventType::Imap(ImapEvent::RawInput) => "imap.raw-input", @@ -1640,6 +1642,7 @@ impl EventType { EventType::Imap(ImapEvent::Subscribe) => 192, EventType::Imap(ImapEvent::Unsubscribe) => 194, EventType::Imap(ImapEvent::Thread) => 193, + EventType::Imap(ImapEvent::UidBatches) => 634, EventType::Imap(ImapEvent::GetQuota) => 57, EventType::Imap(ImapEvent::Error) => 168, EventType::Imap(ImapEvent::RawInput) => 183, @@ -2279,6 +2282,7 @@ impl EventType { 192 => Some(EventType::Imap(ImapEvent::Subscribe)), 194 => Some(EventType::Imap(ImapEvent::Unsubscribe)), 193 => Some(EventType::Imap(ImapEvent::Thread)), + 634 => Some(EventType::Imap(ImapEvent::UidBatches)), 57 => Some(EventType::Imap(ImapEvent::GetQuota)), 168 => Some(EventType::Imap(ImapEvent::Error)), 183 => Some(EventType::Imap(ImapEvent::RawInput)), @@ -3346,6 +3350,7 @@ impl EventType { EventType::Imap(ImapEvent::Subscribe) => "IMAP SUBSCRIBE command", EventType::Imap(ImapEvent::Unsubscribe) => "IMAP UNSUBSCRIBE command", EventType::Imap(ImapEvent::Thread) => "IMAP THREAD command", + EventType::Imap(ImapEvent::UidBatches) => "IMAP UIDBATCHES command", EventType::Imap(ImapEvent::GetQuota) => "IMAP GETQUOTA command", EventType::Imap(ImapEvent::Error) => "IMAP error occurred", EventType::Imap(ImapEvent::RawInput) => "Raw IMAP input received", @@ -3933,6 +3938,7 @@ impl EventType { EventType::Imap(ImapEvent::Subscribe) => "IMAP error", EventType::Imap(ImapEvent::Unsubscribe) => "IMAP error", EventType::Imap(ImapEvent::Thread) => "IMAP error", + EventType::Imap(ImapEvent::UidBatches) => "IMAP error", EventType::Imap(ImapEvent::GetQuota) => "IMAP error", EventType::Imap(ImapEvent::Error) => "IMAP error", EventType::Imap(ImapEvent::RawInput) => "IMAP error", @@ -4376,6 +4382,7 @@ impl EventType { EventType::Imap(ImapEvent::Subscribe), EventType::Imap(ImapEvent::Unsubscribe), EventType::Imap(ImapEvent::Thread), + EventType::Imap(ImapEvent::UidBatches), EventType::Imap(ImapEvent::GetQuota), EventType::Imap(ImapEvent::Error), EventType::Imap(ImapEvent::RawInput), diff --git a/resources/schema/schema.json.gz b/resources/schema/schema.json.gz index 4dc96a24..67e4acff 100644 Binary files a/resources/schema/schema.json.gz and b/resources/schema/schema.json.gz differ diff --git a/resources/schema/schema.json.sha256 b/resources/schema/schema.json.sha256 index b27ad1b5..06d163fb 100644 --- a/resources/schema/schema.json.sha256 +++ b/resources/schema/schema.json.sha256 @@ -1 +1 @@ -5aAD3RctWrFLt6C3WdnRedicMikC_31enuyEuKYiZfU \ No newline at end of file +6vLaEYeoBdNWTwRA5Ma0_L_Vz6CSGTxTuBv25Ykpe5Q \ No newline at end of file