mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-14 07:05:24 +03:00
Update version and cleanup
This commit is contained in:
parent
0a3988ba73
commit
64f9c0e67f
@ -5,7 +5,7 @@ from multiprocessing.synchronize import Event as MpEvent
|
|||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from frigate.comms.events_updater import EventEndPublisher, EventUpdateSubscriber
|
from frigate.comms.events_updater import EventEndPublisher, EventUpdateSubscriber
|
||||||
from frigate.config import EventsConfig, FrigateConfig
|
from frigate.config import FrigateConfig
|
||||||
from frigate.events.types import EventStateEnum, EventTypeEnum
|
from frigate.events.types import EventStateEnum, EventTypeEnum
|
||||||
from frigate.models import Event
|
from frigate.models import Event
|
||||||
from frigate.util.builtin import to_relative_box
|
from frigate.util.builtin import to_relative_box
|
||||||
|
|||||||
@ -69,22 +69,27 @@ class RecordingCleanup(threading.Thread):
|
|||||||
detection_expire_date = (
|
detection_expire_date = (
|
||||||
now - datetime.timedelta(days=config.record.detections.retain.days)
|
now - datetime.timedelta(days=config.record.detections.retain.days)
|
||||||
).timestamp()
|
).timestamp()
|
||||||
expired_reviews: ReviewSegment = ReviewSegment.select(ReviewSegment.id).where(
|
expired_reviews: ReviewSegment = (
|
||||||
ReviewSegment.camera == config.name
|
ReviewSegment.select(ReviewSegment.id)
|
||||||
and (
|
.where(
|
||||||
(
|
ReviewSegment.camera == config.name
|
||||||
ReviewSegment.severity == "alert"
|
and (
|
||||||
and ReviewSegment.end_time < alert_expire_date
|
(
|
||||||
)
|
ReviewSegment.severity == "alert"
|
||||||
or (
|
and ReviewSegment.end_time < alert_expire_date
|
||||||
ReviewSegment.severity == "detection"
|
)
|
||||||
and ReviewSegment.end_time < detection_expire_date
|
or (
|
||||||
|
ReviewSegment.severity == "detection"
|
||||||
|
and ReviewSegment.end_time < detection_expire_date
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
.namedtuples()
|
||||||
)
|
)
|
||||||
|
|
||||||
max_deletes = 100000
|
max_deletes = 100000
|
||||||
deleted_reviews_list = list(expired_reviews)
|
deleted_reviews_list = list(map(lambda x: x[0], expired_reviews))
|
||||||
|
logger.info(f"the list is {deleted_reviews_list}")
|
||||||
for i in range(0, len(deleted_reviews_list), max_deletes):
|
for i in range(0, len(deleted_reviews_list), max_deletes):
|
||||||
ReviewSegment.delete().where(
|
ReviewSegment.delete().where(
|
||||||
ReviewSegment.id << deleted_reviews_list[i : i + max_deletes]
|
ReviewSegment.id << deleted_reviews_list[i : i + max_deletes]
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from playhouse.sqliteq import SqliteQueueDatabase
|
|||||||
from setproctitle import setproctitle
|
from setproctitle import setproctitle
|
||||||
|
|
||||||
from frigate.config import FrigateConfig
|
from frigate.config import FrigateConfig
|
||||||
from frigate.models import Event, Recordings
|
from frigate.models import Recordings, ReviewSegment
|
||||||
from frigate.record.maintainer import RecordingMaintainer
|
from frigate.record.maintainer import RecordingMaintainer
|
||||||
from frigate.util.services import listen
|
from frigate.util.services import listen
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ def manage_recordings(config: FrigateConfig) -> None:
|
|||||||
},
|
},
|
||||||
timeout=max(60, 10 * len([c for c in config.cameras.values() if c.enabled])),
|
timeout=max(60, 10 * len([c for c in config.cameras.values() if c.enabled])),
|
||||||
)
|
)
|
||||||
models = [Event, Recordings]
|
models = [ReviewSegment, Recordings]
|
||||||
db.bind(models)
|
db.bind(models)
|
||||||
|
|
||||||
maintainer = RecordingMaintainer(
|
maintainer = RecordingMaintainer(
|
||||||
|
|||||||
@ -381,9 +381,7 @@ class TestConfig(unittest.TestCase):
|
|||||||
def test_motion_mask_relative_matches_explicit(self):
|
def test_motion_mask_relative_matches_explicit(self):
|
||||||
config = {
|
config = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"record": {
|
"record": {"alerts": {"retain": {"days": 20}}},
|
||||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
|
||||||
},
|
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"explicit": {
|
"explicit": {
|
||||||
"ffmpeg": {
|
"ffmpeg": {
|
||||||
@ -581,7 +579,11 @@ class TestConfig(unittest.TestCase):
|
|||||||
config = {
|
config = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"record": {
|
"record": {
|
||||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
"alerts": {
|
||||||
|
"retain": {
|
||||||
|
"days": 20,
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"back": {
|
"back": {
|
||||||
@ -605,7 +607,11 @@ class TestConfig(unittest.TestCase):
|
|||||||
config = {
|
config = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"record": {
|
"record": {
|
||||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
"alerts": {
|
||||||
|
"retain": {
|
||||||
|
"days": 20,
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"back": {
|
"back": {
|
||||||
@ -629,7 +635,11 @@ class TestConfig(unittest.TestCase):
|
|||||||
config = {
|
config = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"record": {
|
"record": {
|
||||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
"alerts": {
|
||||||
|
"retain": {
|
||||||
|
"days": 20,
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"back": {
|
"back": {
|
||||||
@ -660,7 +670,11 @@ class TestConfig(unittest.TestCase):
|
|||||||
config = {
|
config = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"record": {
|
"record": {
|
||||||
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
|
"alerts": {
|
||||||
|
"retain": {
|
||||||
|
"days": 20,
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"back": {
|
"back": {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ from frigate.util.services import get_video_properties
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
CURRENT_CONFIG_VERSION = "0.14.1-0"
|
CURRENT_CONFIG_VERSION = "0.15-0"
|
||||||
|
|
||||||
|
|
||||||
def migrate_frigate_config(config_file: str):
|
def migrate_frigate_config(config_file: str):
|
||||||
@ -55,12 +55,12 @@ def migrate_frigate_config(config_file: str):
|
|||||||
os.path.join(EXPORT_DIR, file), os.path.join(EXPORT_DIR, new_name)
|
os.path.join(EXPORT_DIR, file), os.path.join(EXPORT_DIR, new_name)
|
||||||
)
|
)
|
||||||
|
|
||||||
if previous_version < "0.14.1-0":
|
if previous_version < "0.15-0":
|
||||||
logger.info(f"Migrating frigate config from {previous_version} to 0.14.1-0...")
|
logger.info(f"Migrating frigate config from {previous_version} to 0.15-0...")
|
||||||
new_config = migrate_0141_0(config)
|
new_config = migrate_015_0(config)
|
||||||
with open(config_file, "w") as f:
|
with open(config_file, "w") as f:
|
||||||
yaml.dump(new_config, f)
|
yaml.dump(new_config, f)
|
||||||
previous_version = "0.14.1-0"
|
previous_version = "0.15-0"
|
||||||
|
|
||||||
logger.info("Finished frigate config migration...")
|
logger.info("Finished frigate config migration...")
|
||||||
|
|
||||||
@ -152,8 +152,8 @@ def migrate_014(config: dict[str, dict[str, any]]) -> dict[str, dict[str, any]]:
|
|||||||
return new_config
|
return new_config
|
||||||
|
|
||||||
|
|
||||||
def migrate_0141_0(config: dict[str, dict[str, any]]) -> dict[str, dict[str, any]]:
|
def migrate_015_0(config: dict[str, dict[str, any]]) -> dict[str, dict[str, any]]:
|
||||||
"""Handle migrating frigate config to 0.14.1-0"""
|
"""Handle migrating frigate config to 0.15-0"""
|
||||||
new_config = config.copy()
|
new_config = config.copy()
|
||||||
|
|
||||||
# migrate record.events to record.alerts and record.detections
|
# migrate record.events to record.alerts and record.detections
|
||||||
@ -240,7 +240,7 @@ def migrate_0141_0(config: dict[str, dict[str, any]]) -> dict[str, dict[str, any
|
|||||||
|
|
||||||
new_config["cameras"][name] = camera_config
|
new_config["cameras"][name] = camera_config
|
||||||
|
|
||||||
new_config["version"] = "0.14.1-0"
|
new_config["version"] = "0.15-0"
|
||||||
return new_config
|
return new_config
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user