From c067dbd9f71e1958e2455a0bd45538edde983617 Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Sat, 26 Oct 2024 22:12:24 +0100 Subject: [PATCH] Filter out on-going events Unifi Protect has started to return events that have not ended. These are now explicitly filtered out --- unifi_protect_backup/missing_event_checker.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/unifi_protect_backup/missing_event_checker.py b/unifi_protect_backup/missing_event_checker.py index 24b5f63..6c245f4 100644 --- a/unifi_protect_backup/missing_event_checker.py +++ b/unifi_protect_backup/missing_event_checker.py @@ -77,9 +77,11 @@ class MissingEventChecker: if not events_chunk: break # There were no events to backup - assert events_chunk[-1].end is not None - start_time = events_chunk[-1].end - unifi_events = {event.id: event for event in events_chunk} + # Filter out on-going events + unifi_events = {event.id: event for event in events_chunk if event.end is not None} + + # Next chunks start time should be the end of the oldest complete event in the current chunk + start_time = max([event.end for event in unifi_events.values()]) # Get list of events that have been backed up from the database