From 52b9614db28fc7d298a011696b3bc3f6f5a6d1d7 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Sat, 8 Oct 2022 18:41:11 -0600 Subject: [PATCH] Store the segment size in db --- frigate/record.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frigate/record.py b/frigate/record.py index c602b4a98..29f4db0b9 100644 --- a/frigate/record.py +++ b/frigate/record.py @@ -283,6 +283,10 @@ class RecordingMaintainer(threading.Thread): logger.debug( f"Copied {file_path} in {datetime.datetime.now().timestamp()-start_frame} seconds." ) + try: + segment_size = float(os.stat(file_path)) / 1000 + except OSError: + segment_size = -1 rand_id = "".join( random.choices(string.ascii_lowercase + string.digits, k=6) @@ -297,10 +301,8 @@ class RecordingMaintainer(threading.Thread): motion=motion_count, # TODO: update this to store list of active objects at some point objects=active_count, + segment_size=segment_size, ) - else: - logger.warning(f"Ignoring segment because {file_path} already exists.") - os.remove(cache_path) except Exception as e: logger.error(f"Unable to store recording segment {cache_path}") Path(cache_path).unlink(missing_ok=True)