From 22ae76c2cee6f60ccf5cf60fb4c09faeba5af684 Mon Sep 17 00:00:00 2001 From: Byson94 Date: Sat, 27 Sep 2025 11:49:59 +0530 Subject: [PATCH] fix: m/min duration end & ewwii crash --- CHANGELOG.md | 1 + crates/shared_utils/src/extract_props.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9a3ad3..ec2af14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - The logs going to `eww_{}.log` instead of `ewwii_{}.log`. - Logs not truncating if it is over 100MB and not deleting if over 7 days old. +- Ewwii crashing on invalid duration property. ## [0.1.4] - 2025-09-18 diff --git a/crates/shared_utils/src/extract_props.rs b/crates/shared_utils/src/extract_props.rs index de877b7..3bd3a84 100644 --- a/crates/shared_utils/src/extract_props.rs +++ b/crates/shared_utils/src/extract_props.rs @@ -116,20 +116,21 @@ pub fn get_duration_prop(props: &Map, key: &str, default: Option) -> R Ok(Duration::from_secs(s)) } else if key_str.ends_with("min") { let num = &key_str[..key_str.len() - 3]; - let mins = num.parse::() - .map_err(|_| anyhow!("Invalid min value: '{}'", key_str))?; + let mins = + num.parse::().map_err(|_| anyhow!("Invalid min value: '{}'", key_str))?; Ok(Duration::from_secs(mins * 60)) } else if key_str.ends_with("m") { let num = &key_str[..key_str.len() - 1]; - let mins = num.parse::() - .map_err(|_| anyhow!("Invalid m value: '{}'", key_str))?; + let mins = num.parse::().map_err(|_| anyhow!("Invalid m value: '{}'", key_str))?; Ok(Duration::from_secs(mins * 60)) } else if key_str.ends_with("h") { let num = &key_str[..key_str.len() - 1]; let hrs = num.parse::().map_err(|_| anyhow!("Invalid h value: '{}'", key_str))?; Ok(Duration::from_secs(hrs * 3600)) } else { - Err(anyhow!("Unsupported duration format: '{}'", key_str)) + default.ok_or_else(|| { + anyhow!("Unsupported duration format: '{}', and no default provided", key_str) + }) } } else { default.ok_or_else(|| anyhow!("No value for duration and no default provided"))