mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-01-26 00:06:32 +01:00
moar speed
This commit is contained in:
parent
56480dc1ef
commit
6c28613def
@ -214,33 +214,24 @@ class RecordingCleanup(threading.Thread):
|
|||||||
# that start after the previous recording segment ended
|
# that start after the previous recording segment ended
|
||||||
for idx in range(event_start, len(events)):
|
for idx in range(event_start, len(events)):
|
||||||
event = events[idx]
|
event = events[idx]
|
||||||
# logger.debug(f"Checking event {event.id}")
|
|
||||||
if (
|
# if the next event ends before this segment starts, break
|
||||||
( # event starts in this segment
|
if event.end_time < recording.start_time:
|
||||||
event.start_time > recording.start_time
|
|
||||||
and event.start_time < recording.end_time
|
|
||||||
)
|
|
||||||
or ( # event ends in this segment
|
|
||||||
event.end_time > recording.start_time
|
|
||||||
and event.end_time < recording.end_time
|
|
||||||
)
|
|
||||||
or ( # event spans this segment
|
|
||||||
recording.start_time > event.start_time
|
|
||||||
and recording.end_time < event.end_time
|
|
||||||
)
|
|
||||||
):
|
|
||||||
keep = True
|
|
||||||
break
|
break
|
||||||
|
|
||||||
# if the event starts after the current recording, skip it next time
|
# if the next event starts after the current segment ends, skip it
|
||||||
if event.start_time > recording.end_time:
|
if event.start_time > recording.end_time:
|
||||||
event_start = idx
|
event_start = idx
|
||||||
|
continue
|
||||||
|
|
||||||
|
keep = True
|
||||||
|
|
||||||
# Delete recordings outside of the retention window
|
# Delete recordings outside of the retention window
|
||||||
if not keep:
|
if not keep:
|
||||||
Path(recording.path).unlink(missing_ok=True)
|
Path(recording.path).unlink(missing_ok=True)
|
||||||
deleted_recordings.add(recording.id)
|
deleted_recordings.add(recording.id)
|
||||||
|
|
||||||
|
logger.debug(f"Expiring {len(deleted_recordings)} recordings")
|
||||||
(Recordings.delete().where(Recordings.id << deleted_recordings).execute())
|
(Recordings.delete().where(Recordings.id << deleted_recordings).execute())
|
||||||
|
|
||||||
logger.debug(f"End camera: {camera}.")
|
logger.debug(f"End camera: {camera}.")
|
||||||
|
Loading…
Reference in New Issue
Block a user