mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 17:25:22 +03:00
Add expire interval option for snaphots
This commit is contained in:
parent
7c60753ab0
commit
b8311071f2
@ -440,6 +440,10 @@ class CameraFfmpegConfig(FfmpegConfig):
|
||||
|
||||
class SnapshotsConfig(FrigateBaseModel):
|
||||
enabled: bool = Field(default=False, title="Snapshots enabled.")
|
||||
expire_interval: int = Field(
|
||||
default=5,
|
||||
title="Number of minutes to wait between cleanup runs.",
|
||||
)
|
||||
clean_copy: bool = Field(
|
||||
default=True, title="Create a clean copy of the snapshot image."
|
||||
)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import datetime
|
||||
import itertools
|
||||
import logging
|
||||
import os
|
||||
import queue
|
||||
@ -289,15 +290,18 @@ class EventCleanup(threading.Thread):
|
||||
|
||||
def run(self):
|
||||
# only expire events every 5 minutes
|
||||
while not self.stop_event.wait(300):
|
||||
self.expire("clips")
|
||||
self.expire("snapshots")
|
||||
self.purge_duplicates()
|
||||
for counter in itertools.cycle(range(self.config.snapshots.expire_interval)):
|
||||
if self.stop_event.wait(60):
|
||||
logger.info(f"Exiting event cleanup...")
|
||||
break
|
||||
|
||||
# drop events from db where has_clip and has_snapshot are false
|
||||
delete_query = Event.delete().where(
|
||||
Event.has_clip == False, Event.has_snapshot == False
|
||||
)
|
||||
delete_query.execute()
|
||||
if counter == 0:
|
||||
self.expire("clips")
|
||||
self.expire("snapshots")
|
||||
self.purge_duplicates()
|
||||
|
||||
logger.info(f"Exiting event cleanup...")
|
||||
# drop events from db where has_clip and has_snapshot are false
|
||||
delete_query = Event.delete().where(
|
||||
Event.has_clip == False, Event.has_snapshot == False
|
||||
)
|
||||
delete_query.execute()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user