From 7d65c059941038f297ad65f6e349243e7ef6e114 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Mon, 30 Aug 2021 06:58:50 -0500 Subject: [PATCH] properly handle scenario with no recordings --- frigate/record.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/frigate/record.py b/frigate/record.py index 2ceda3652..65cf8e2cc 100644 --- a/frigate/record.py +++ b/frigate/record.py @@ -10,8 +10,7 @@ import threading from pathlib import Path import psutil - -from peewee import JOIN +from peewee import JOIN, DoesNotExist from frigate.config import FrigateConfig from frigate.const import CACHE_DIR, RECORD_DIR @@ -261,15 +260,14 @@ class RecordingCleanup(threading.Thread): ) # find all the recordings older than the oldest recording in the db - oldest_recording = ( - Recordings.select().order_by(Recordings.start_time.desc()).get() - ) + try: + oldest_recording = ( + Recordings.select().order_by(Recordings.start_time.desc()).get() + ) - oldest_timestamp = ( - oldest_recording.start_time - if oldest_recording - else datetime.datetime.now().timestamp() - ) + oldest_timestamp = oldest_recording.start_time + except DoesNotExist: + oldest_timestamp = datetime.datetime.now().timestamp() logger.debug(f"Oldest recording in the db: {oldest_timestamp}") process = sp.run(