Skip to content

Commit

Permalink
fix(spells): correct interpretation of end_sec field [NET-346] (#1431)
Browse files Browse the repository at this point in the history
fix spell rescheduling
  • Loading branch information
kmd-fl authored Jan 26, 2023
1 parent 57e4bdc commit 2b018de
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/spell-event-bus/src/bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ impl Scheduled {
/// Reschedule a spell to `now` + `period`.
/// Return `None` if the spell is supposed to end at the given time `end_at`.
fn at(data: Periodic, now: Instant) -> Option<Scheduled> {
if data.end_at.map(|end_at| end_at <= now).unwrap_or(false) {
// We do checked_add here only to avoid a mere possibility of internal panic.
let run_at = now.checked_add(data.period)?;
if data.end_at.map(|end_at| end_at <= run_at).unwrap_or(false) {
return None;
}

// We do checked_add here only to avoid a mere possibility of internal panic.
let run_at = now.checked_add(data.period)?;
Some(Scheduled { data, run_at })
}
}
Expand Down

0 comments on commit 2b018de

Please sign in to comment.