fix: m/min duration end & ewwii crash
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -116,20 +116,21 @@ pub fn get_duration_prop(props: &Map, key: &str, default: Option<Duration>) -> 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::<u64>()
|
||||
.map_err(|_| anyhow!("Invalid min value: '{}'", key_str))?;
|
||||
let mins =
|
||||
num.parse::<u64>().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::<u64>()
|
||||
.map_err(|_| anyhow!("Invalid m value: '{}'", key_str))?;
|
||||
let mins = num.parse::<u64>().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::<u64>().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"))
|
||||
|
||||
Reference in New Issue
Block a user