style: rustfmt the server, parsing and APPEND changes

This commit is contained in:
Anthony
2026-06-14 22:06:50 +02:00
parent 2283a4cf15
commit c2ceecc3c5
5 changed files with 31 additions and 10 deletions
+2 -1
View File
@@ -40,7 +40,8 @@ pub async fn serve(
{ {
Ok(Ok(tls_stream)) => { Ok(Ok(tls_stream)) => {
if let Err(e) = if let Err(e) =
handle_connection(tls_stream, store, backend, local_store, pw_hash).await handle_connection(tls_stream, store, backend, local_store, pw_hash)
.await
{ {
error!("IMAP connection error: {}", e); error!("IMAP connection error: {}", e);
} }
+4 -1
View File
@@ -1115,7 +1115,10 @@ fn append_first_token(args: &str) -> Option<String> {
fn append_literal_size(args: &str) -> Option<usize> { fn append_literal_size(args: &str) -> Option<usize> {
let open = args.rfind('{')?; let open = args.rfind('{')?;
let close = args[open..].find('}')? + open; let close = args[open..].find('}')? + open;
args[open + 1..close].trim_end_matches('+').parse::<usize>().ok() args[open + 1..close]
.trim_end_matches('+')
.parse::<usize>()
.ok()
} }
#[cfg(test)] #[cfg(test)]
+4 -1
View File
@@ -512,7 +512,10 @@ mod tests {
#[test] #[test]
fn qp_non_utf8_byte_is_decoded_not_echoed() { fn qp_non_utf8_byte_is_decoded_not_echoed() {
let out = decode_quoted_printable("caf=E9"); let out = decode_quoted_printable("caf=E9");
assert!(!out.contains("=E9"), "QP source must be decoded, not echoed"); assert!(
!out.contains("=E9"),
"QP source must be decoded, not echoed"
);
assert!(out.starts_with("caf"), "got {out:?}"); assert!(out.starts_with("caf"), "got {out:?}");
} }
+12 -4
View File
@@ -143,7 +143,8 @@ pub async fn serve(
{ {
Ok(Ok(tls_stream)) => { Ok(Ok(tls_stream)) => {
if let Err(e) = if let Err(e) =
handle_connection(tls_stream, tuta, pw_hash, SmtpLimits::default()).await handle_connection(tls_stream, tuta, pw_hash, SmtpLimits::default())
.await
{ {
error!("SMTP connection error: {}", e); error!("SMTP connection error: {}", e);
} }
@@ -509,7 +510,10 @@ mod tests {
assert!(size_param_exceeds("MAIL FROM:<a@b.com> size=30000000", max)); // case-insensitive assert!(size_param_exceeds("MAIL FROM:<a@b.com> size=30000000", max)); // case-insensitive
assert!(!size_param_exceeds("MAIL FROM:<a@b.com> SIZE=1000", max)); assert!(!size_param_exceeds("MAIL FROM:<a@b.com> SIZE=1000", max));
assert!(!size_param_exceeds("MAIL FROM:<a@b.com>", max)); // no SIZE param assert!(!size_param_exceeds("MAIL FROM:<a@b.com>", max)); // no SIZE param
assert!(!size_param_exceeds("MAIL FROM:<a@b.com> SIZE=notanumber", max)); assert!(!size_param_exceeds(
"MAIL FROM:<a@b.com> SIZE=notanumber",
max
));
} }
#[tokio::test] #[tokio::test]
@@ -672,8 +676,12 @@ mod tests {
let backend = Arc::new(CountingBackend::default()); let backend = Arc::new(CountingBackend::default());
let b = backend.clone(); let b = backend.clone();
let h = tokio::spawn(async move { let h = tokio::spawn(async move {
let _ = let _ = handle_connection(
handle_connection(server, b as Arc<dyn MailBackend>, None, SmtpLimits::default()) server,
b as Arc<dyn MailBackend>,
None,
SmtpLimits::default(),
)
.await; .await;
}); });
+8 -2
View File
@@ -458,7 +458,10 @@ pub async fn run_syncer(
Ok(Some(rfc)) => { Ok(Some(rfc)) => {
let text = extract_body_text(&rfc); let text = extract_body_text(&rfc);
if let Err(e) = ls.index_body(&meta.element_id, &text) { if let Err(e) = ls.index_body(&meta.element_id, &text) {
warn!("FTS backfill failed for {}: {e}", meta.element_id); warn!(
"FTS backfill failed for {}: {e}",
meta.element_id
);
ok = false; ok = false;
} else { } else {
indexed += 1; indexed += 1;
@@ -466,7 +469,10 @@ pub async fn run_syncer(
} }
Ok(None) => {} Ok(None) => {}
Err(e) => { Err(e) => {
warn!("FTS backfill read failed for {}: {e}", meta.element_id); warn!(
"FTS backfill read failed for {}: {e}",
meta.element_id
);
ok = false; ok = false;
} }
} }