From e065738d95a81a6c598e8721a89dbdc61e4f865f Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Tue, 24 Jan 2023 19:25:55 -0300 Subject: [PATCH] Use new db default path in code --- frigate/app.py | 6 +++--- frigate/config.py | 6 ++---- frigate/const.py | 1 + 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/frigate/app.py b/frigate/app.py index 5ffa3d77d..c67a98066 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -17,7 +17,7 @@ from frigate.comms.dispatcher import Communicator, Dispatcher from frigate.comms.mqtt import MqttClient from frigate.comms.ws import WebSocketClient from frigate.config import FrigateConfig -from frigate.const import CACHE_DIR, CLIPS_DIR, RECORD_DIR +from frigate.const import CACHE_DIR, CLIPS_DIR, DEFAULT_DB_PATH, RECORD_DIR from frigate.object_detection import ObjectDetectProcess from frigate.events import EventCleanup, EventProcessor from frigate.http import create_app @@ -54,7 +54,7 @@ class FrigateApp: os.environ[key] = value def ensure_dirs(self) -> None: - for d in [RECORD_DIR, CLIPS_DIR, CACHE_DIR]: + for d in [CONFIG_DIR, RECORD_DIR, CLIPS_DIR, CACHE_DIR]: if not os.path.exists(d) and not os.path.islink(d): logger.info(f"Creating directory: {d}") os.makedirs(d) @@ -134,7 +134,7 @@ class FrigateApp: def init_database(self) -> None: # Migrate DB location - old_db_path = os.path.join(CLIPS_DIR, "frigate.db") + old_db_path = DEFAULT_DB_PATH if not os.path.isfile(self.config.database.path) and os.path.isfile( old_db_path ): diff --git a/frigate/config.py b/frigate/config.py index 9cf20937b..a343676f4 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -13,8 +13,8 @@ from pydantic import BaseModel, Extra, Field, validator, parse_obj_as from pydantic.fields import PrivateAttr from frigate.const import ( - BASE_DIR, CACHE_DIR, + DEFAULT_DB_PATH, REGEX_CAMERA_NAME, YAML_EXT, ) @@ -695,9 +695,7 @@ class CameraConfig(FrigateBaseModel): class DatabaseConfig(FrigateBaseModel): - path: str = Field( - default=os.path.join(BASE_DIR, "frigate.db"), title="Database path." - ) + path: str = Field(default=DEFAULT_DB_PATH, title="Database path.") class LogLevelEnum(str, Enum): diff --git a/frigate/const.py b/frigate/const.py index 528901783..0dbffb2d3 100644 --- a/frigate/const.py +++ b/frigate/const.py @@ -1,3 +1,4 @@ +DEFAULT_DB_PATH = "/config/frigate.db" BASE_DIR = "/media/frigate" CLIPS_DIR = f"{BASE_DIR}/clips" RECORD_DIR = f"{BASE_DIR}/recordings"