mirror of
https://github.com/stalwartlabs/stalwart.git
synced 2026-08-21 08:01:29 +00:00
UIDBATCHES improvements and logging
This commit is contained in:
@@ -42,9 +42,9 @@ impl Request<Command> {
|
||||
"Expected a batch range in the form 'from:to'.",
|
||||
)
|
||||
})?;
|
||||
let from = parse_number::<u32>(from.as_bytes())
|
||||
let from = parse_number::<u32>(from.trim().as_bytes())
|
||||
.map_err(|v| bad(self.tag.to_compact_string(), v))?;
|
||||
let to = parse_number::<u32>(to.as_bytes())
|
||||
let to = parse_number::<u32>(to.trim().as_bytes())
|
||||
.map_err(|v| bad(self.tag.to_compact_string(), v))?;
|
||||
|
||||
if from == 0 || to == 0 {
|
||||
|
||||
@@ -203,8 +203,7 @@ impl<T: SessionStream> SessionData<T> {
|
||||
if ids.len() > message_limit {
|
||||
let mut uids = ids.values().map(|imap_id| imap_id.uid).collect::<Vec<_>>();
|
||||
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
|
||||
|
||||
@@ -170,9 +170,9 @@ impl<T: SessionStream> SessionData<T> {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,8 +222,7 @@ impl<T: SessionStream> SessionData<T> {
|
||||
if ids.len() > message_limit {
|
||||
let mut uids = ids.values().map(|imap_id| imap_id.uid).collect::<Vec<_>>();
|
||||
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 {
|
||||
|
||||
@@ -97,10 +97,11 @@ impl<T: SessionStream> Session<T> {
|
||||
}
|
||||
|
||||
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()
|
||||
);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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),
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
5aAD3RctWrFLt6C3WdnRedicMikC_31enuyEuKYiZfU
|
||||
6vLaEYeoBdNWTwRA5Ma0_L_Vz6CSGTxTuBv25Ykpe5Q
|
||||
Reference in New Issue
Block a user