Skip to content

Commit

Permalink
refactor: swap to unwrap_or to utilize duration
Browse files Browse the repository at this point in the history
  • Loading branch information
bconn98 committed Jul 10, 2024
1 parent 4e47fb2 commit 4263205
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/append/rolling_file/policy/compound/trigger/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ impl TimeTrigger {
#[cfg(not(test))]
let current = Local::now();
// In the case where bad user input results in an invalid next time, provide a valid time.
let next_time = TimeTrigger::get_next_time(current, config.interval, config.modulate).unwrap_or(i64::MAX);
let next_time = TimeTrigger::get_next_time(current, config.interval, config.modulate)
.unwrap_or(current + Duration::try_seconds(1_i64).unwrap());
let next_roll_time = if config.max_random_delay > 0 {
let random_delay = rand::thread_rng().gen_range(0..config.max_random_delay);
// This is a valid unwrap because chrono::Duration::try_milliseconds accepts an i64
Expand Down

0 comments on commit 4263205

Please sign in to comment.