v114
This commit is contained in:
+10
-2
@@ -57,8 +57,16 @@ class Config:
|
||||
|
||||
def load_config(path: str | None = None) -> Config:
|
||||
path = path or os.environ.get("NVR_CONFIG", "cameras.yaml")
|
||||
with open(path, "r", encoding="utf-8") as fh:
|
||||
raw = yaml.safe_load(fh) or {}
|
||||
# Толерантно к отсутствию/повреждению: если файла нет, на его месте каталог
|
||||
# (битый bind-mount) или YAML невалиден — стартуем без камер (добавляются из UI),
|
||||
# а не падаем с ошибкой на старте.
|
||||
raw: dict = {}
|
||||
if os.path.isfile(path):
|
||||
try:
|
||||
with open(path, "r", encoding="utf-8") as fh:
|
||||
raw = yaml.safe_load(fh) or {}
|
||||
except (OSError, yaml.YAMLError):
|
||||
raw = {}
|
||||
|
||||
storage = Storage(**(raw.get("storage") or {}))
|
||||
live = Live(**(raw.get("live") or {}))
|
||||
|
||||
Reference in New Issue
Block a user