mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-04 02:05:21 +03:00
Use new db default path in code
This commit is contained in:
parent
29123dacb5
commit
e065738d95
@ -17,7 +17,7 @@ from frigate.comms.dispatcher import Communicator, Dispatcher
|
|||||||
from frigate.comms.mqtt import MqttClient
|
from frigate.comms.mqtt import MqttClient
|
||||||
from frigate.comms.ws import WebSocketClient
|
from frigate.comms.ws import WebSocketClient
|
||||||
from frigate.config import FrigateConfig
|
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.object_detection import ObjectDetectProcess
|
||||||
from frigate.events import EventCleanup, EventProcessor
|
from frigate.events import EventCleanup, EventProcessor
|
||||||
from frigate.http import create_app
|
from frigate.http import create_app
|
||||||
@ -54,7 +54,7 @@ class FrigateApp:
|
|||||||
os.environ[key] = value
|
os.environ[key] = value
|
||||||
|
|
||||||
def ensure_dirs(self) -> None:
|
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):
|
if not os.path.exists(d) and not os.path.islink(d):
|
||||||
logger.info(f"Creating directory: {d}")
|
logger.info(f"Creating directory: {d}")
|
||||||
os.makedirs(d)
|
os.makedirs(d)
|
||||||
@ -134,7 +134,7 @@ class FrigateApp:
|
|||||||
|
|
||||||
def init_database(self) -> None:
|
def init_database(self) -> None:
|
||||||
# Migrate DB location
|
# 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(
|
if not os.path.isfile(self.config.database.path) and os.path.isfile(
|
||||||
old_db_path
|
old_db_path
|
||||||
):
|
):
|
||||||
|
|||||||
@ -13,8 +13,8 @@ from pydantic import BaseModel, Extra, Field, validator, parse_obj_as
|
|||||||
from pydantic.fields import PrivateAttr
|
from pydantic.fields import PrivateAttr
|
||||||
|
|
||||||
from frigate.const import (
|
from frigate.const import (
|
||||||
BASE_DIR,
|
|
||||||
CACHE_DIR,
|
CACHE_DIR,
|
||||||
|
DEFAULT_DB_PATH,
|
||||||
REGEX_CAMERA_NAME,
|
REGEX_CAMERA_NAME,
|
||||||
YAML_EXT,
|
YAML_EXT,
|
||||||
)
|
)
|
||||||
@ -695,9 +695,7 @@ class CameraConfig(FrigateBaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class DatabaseConfig(FrigateBaseModel):
|
class DatabaseConfig(FrigateBaseModel):
|
||||||
path: str = Field(
|
path: str = Field(default=DEFAULT_DB_PATH, title="Database path.")
|
||||||
default=os.path.join(BASE_DIR, "frigate.db"), title="Database path."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class LogLevelEnum(str, Enum):
|
class LogLevelEnum(str, Enum):
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
DEFAULT_DB_PATH = "/config/frigate.db"
|
||||||
BASE_DIR = "/media/frigate"
|
BASE_DIR = "/media/frigate"
|
||||||
CLIPS_DIR = f"{BASE_DIR}/clips"
|
CLIPS_DIR = f"{BASE_DIR}/clips"
|
||||||
RECORD_DIR = f"{BASE_DIR}/recordings"
|
RECORD_DIR = f"{BASE_DIR}/recordings"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user