diff --git a/crates/imap-proto/src/parser/select.rs b/crates/imap-proto/src/parser/select.rs index d5f5f31c..c5f4a8b1 100644 --- a/crates/imap-proto/src/parser/select.rs +++ b/crates/imap-proto/src/parser/select.rs @@ -321,6 +321,21 @@ mod tests { .into(), }, ), + ( + "A12 SELECT \"INBOX\" (QRESYNC (1693237464 16582))\r\n", + select::Arguments { + mailbox_name: "INBOX".to_string(), + tag: "A12".to_string(), + condstore: false, + qresync: QResync { + uid_validity: 1693237464, + modseq: 16582, + known_uids: None, + seq_match: None, + } + .into(), + }, + ), ] { assert_eq!( receiver diff --git a/crates/imap/src/core/writer.rs b/crates/imap/src/core/writer.rs index 42f4114e..99afd990 100644 --- a/crates/imap/src/core/writer.rs +++ b/crates/imap/src/core/writer.rs @@ -98,6 +98,13 @@ pub fn spawn_writer(mut stream: Event, span: tracing::Span) -> mpsc::Sender { + tracing::trace!( + parent: &span, + event = "write", + data = std::str::from_utf8(bytes.as_ref()).unwrap_or_default(), + size = bytes.len() + ); + match stream_tx.write_all(bytes.as_ref()).await { Ok(_) => { let _ = stream_tx.flush().await; diff --git a/crates/imap/src/op/select.rs b/crates/imap/src/op/select.rs index 1f0e9ee4..8805c70d 100644 --- a/crates/imap/src/op/select.rs +++ b/crates/imap/src/op/select.rs @@ -24,7 +24,7 @@ use std::sync::Arc; use imap_proto::{ - protocol::{fetch, list::ListItem, select::Response, ImapResponse}, + protocol::{fetch, list::ListItem, select::Response, ImapResponse, Sequence}, receiver::Request, Command, ResponseCode, StatusResponse, }; @@ -93,7 +93,11 @@ impl Session { tag: String::new(), sequence_set: qresync .known_uids - .unwrap_or_else(|| qresync.seq_match.unwrap().1), + .or_else(|| qresync.seq_match.map(|(_, s)| s)) + .unwrap_or(Sequence::Range { + start: 1.into(), + end: None, + }), attributes: vec![fetch::Attribute::Flags], changed_since: qresync.modseq.into(), include_vanished: true,