mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35: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):
|
class SnapshotsConfig(FrigateBaseModel):
|
||||||
enabled: bool = Field(default=False, title="Snapshots enabled.")
|
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(
|
clean_copy: bool = Field(
|
||||||
default=True, title="Create a clean copy of the snapshot image."
|
default=True, title="Create a clean copy of the snapshot image."
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import queue
|
import queue
|
||||||
@ -289,15 +290,18 @@ class EventCleanup(threading.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# only expire events every 5 minutes
|
# only expire events every 5 minutes
|
||||||
while not self.stop_event.wait(300):
|
for counter in itertools.cycle(range(self.config.snapshots.expire_interval)):
|
||||||
self.expire("clips")
|
if self.stop_event.wait(60):
|
||||||
self.expire("snapshots")
|
logger.info(f"Exiting event cleanup...")
|
||||||
self.purge_duplicates()
|
break
|
||||||
|
|
||||||
# drop events from db where has_clip and has_snapshot are false
|
if counter == 0:
|
||||||
delete_query = Event.delete().where(
|
self.expire("clips")
|
||||||
Event.has_clip == False, Event.has_snapshot == False
|
self.expire("snapshots")
|
||||||
)
|
self.purge_duplicates()
|
||||||
delete_query.execute()
|
|
||||||
|
|
||||||
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