from __future__ import annotations import os from dataclasses import dataclass @dataclass(frozen=True) class Settings: root_aliases: dict[str, str] task_db_path: str DEFAULT_ROOT_ALIASES = { "storage1": "/Volumes/8TB", "storage2": "/Volumes/8TB_RAID1", } def _load_root_aliases() -> dict[str, str]: # Minimal env override format: storage1=/path1,storage2=/path2 raw = os.getenv("WEBMANAGER_ROOT_ALIASES", "").strip() if not raw: return dict(DEFAULT_ROOT_ALIASES) parsed: dict[str, str] = {} for entry in raw.split(","): if "=" not in entry: continue alias, root = entry.split("=", 1) alias = alias.strip() root = root.strip() if alias and root: parsed[alias] = root return parsed or dict(DEFAULT_ROOT_ALIASES) def get_settings() -> Settings: task_db_path = os.getenv("WEBMANAGER_TASK_DB_PATH", "webui/backend/data/tasks.db").strip() return Settings(root_aliases=_load_root_aliases(), task_db_path=task_db_path)