From 79599f2f9c271054eea0cc21970c6bdcf62a7f7c Mon Sep 17 00:00:00 2001 From: mdecimus Date: Sat, 26 Aug 2023 13:13:37 +0200 Subject: [PATCH] Do not panic when report hash = 0 (#60) --- crates/smtp/src/reporting/scheduler.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/crates/smtp/src/reporting/scheduler.rs b/crates/smtp/src/reporting/scheduler.rs index c63a34da..a6650e15 100644 --- a/crates/smtp/src/reporting/scheduler.rs +++ b/crates/smtp/src/reporting/scheduler.rs @@ -205,16 +205,15 @@ impl SMTP { .eval(&RecipientDomain::new(domain)) .await .clone(); - path.push( - (policy - % *self - .report - .config - .hash - .eval(&RecipientDomain::new(domain)) - .await) - .to_string(), - ); + let hash = *self + .report + .config + .hash + .eval(&RecipientDomain::new(domain)) + .await; + if hash > 0 { + path.push((policy % hash).to_string()); + } let _ = fs::create_dir(&path).await; // Build filename