Fix event getting stuck due to only checking current clip / snapshot (#21893)

* Fix event getting stuck due to only checking current clip / snapshot

* formatting
This commit is contained in:
Nicolas Mowen 2026-02-05 07:43:19 -07:00 committed by GitHub
parent a8ab82937b
commit c9ba851f0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,6 +15,16 @@ logger = logging.getLogger(__name__)
def should_update_db(prev_event: Event, current_event: Event) -> bool: def should_update_db(prev_event: Event, current_event: Event) -> bool:
"""If current_event has updated fields and (clip or snapshot).""" """If current_event has updated fields and (clip or snapshot)."""
# If event is ending and was previously saved, always update to set end_time
# This ensures events are properly ended even when alerts/detections are disabled
# mid-event (which can cause has_clip/has_snapshot to become False)
if (
prev_event["end_time"] is None
and current_event["end_time"] is not None
and (prev_event["has_clip"] or prev_event["has_snapshot"])
):
return True
if current_event["has_clip"] or current_event["has_snapshot"]: if current_event["has_clip"] or current_event["has_snapshot"]:
# if this is the first time has_clip or has_snapshot turned true # if this is the first time has_clip or has_snapshot turned true
if not prev_event["has_clip"] and not prev_event["has_snapshot"]: if not prev_event["has_clip"] and not prev_event["has_snapshot"]: