mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
Catch case where no recordings exist for camera
This commit is contained in:
parent
310aa0d3f0
commit
6502a52225
@ -31,12 +31,12 @@ class StorageMaintainer(threading.Thread):
|
||||
|
||||
for camera in self.config.cameras.keys():
|
||||
# get average of non-zero segment sizes to ignore segment with no value
|
||||
avg_segment_size = round(
|
||||
segment_query = (
|
||||
Recordings.select(fn.AVG(Recordings.segment_size))
|
||||
.where(Recordings.camera == camera, Recordings.segment_size != 0)
|
||||
.scalar(),
|
||||
2,
|
||||
.scalar()
|
||||
)
|
||||
avg_segment_size = round(segment_query, 2) if segment_query else 0
|
||||
|
||||
# get average of an hour using the average segment size
|
||||
segment_duration = int(
|
||||
@ -148,7 +148,9 @@ class StorageMaintainer(threading.Thread):
|
||||
|
||||
# check if 2 hours of segments were deleted from the 24 retrieved
|
||||
if len(deleted_recordings) < segment_count:
|
||||
logger.debug(f"segment target of {segment_count} > {len(deleted_recordings)}, pulling all non-retained recordings")
|
||||
logger.debug(
|
||||
f"segment target of {segment_count} > {len(deleted_recordings)}, pulling all non-retained recordings"
|
||||
)
|
||||
# get the rest of the recording segments to look through
|
||||
recordings: Recordings = (
|
||||
Recordings.select()
|
||||
@ -162,7 +164,9 @@ class StorageMaintainer(threading.Thread):
|
||||
|
||||
# check if still 2 hour quota still not meant
|
||||
if len(deleted_recordings) < segment_count:
|
||||
logger.debug(f"segment target of {segment_count} > {len(deleted_recordings)}, pulling all recordings")
|
||||
logger.debug(
|
||||
f"segment target of {segment_count} > {len(deleted_recordings)}, pulling all recordings"
|
||||
)
|
||||
recordings: Recordings = (
|
||||
Recordings.select()
|
||||
.where(Recordings.camera == camera)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user