From 2cc9a15f6aa624555ce34bfd085fcae7fcf2ea74 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Sat, 19 Dec 2020 15:52:09 -0600 Subject: [PATCH] handle scenario with empty cache --- frigate/events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frigate/events.py b/frigate/events.py index b8f63f168..75ad94649 100644 --- a/frigate/events.py +++ b/frigate/events.py @@ -101,7 +101,7 @@ class EventProcessor(threading.Thread): # get all clips from the camera with the event sorted sorted_clips = sorted([c for c in self.cached_clips.values() if c['camera'] == camera], key = lambda i: i['start_time']) - while sorted_clips[-1]['start_time'] + sorted_clips[-1]['duration'] < event_data['end_time']+post_capture: + while len(sorted_clips) == 0 or sorted_clips[-1]['start_time'] + sorted_clips[-1]['duration'] < event_data['end_time']+post_capture: time.sleep(5) self.refresh_cache() # get all clips from the camera with the event sorted