from pathlib import Path

from app.core.config import settings

DATA_ROOT = Path(settings.data_root)


def ensure_data_dirs() -> None:
    for name in ["uploads", "error-reports", "exports", "pdf-cache", "db-backups"]:
        (DATA_ROOT / name).mkdir(parents=True, exist_ok=True)


def data_path(name: str) -> Path:
    ensure_data_dirs()
    return DATA_ROOT / name
