Store the segment size in db

This commit is contained in:
Nick Mowen 2022-10-08 18:41:11 -06:00
parent bb3aee3698
commit 52b9614db2

View File

@ -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)