Ensure data/, data/exports/, and data/downloads/ are created at startup

Add _ensure_data_dirs() helper in main.py and call it from both _run_setup()
and _start_service() so all required data directories are guaranteed to exist
before any module attempts to use them.

https://claude.ai/code/session_01KjaNo9RXevw6x1DjJD8mj6
This commit is contained in:
Claude
2026-03-24 21:10:10 +00:00
parent 51cec55f44
commit 052ec1f39e
+11
View File
@@ -82,6 +82,13 @@ def main(
# Setup
# ---------------------------------------------------------------------------
def _ensure_data_dirs() -> None:
"""Create data/, data/exports/, and data/downloads/ if they don't exist."""
base = Path(__file__).parent / "data"
for sub in ("", "exports", "downloads"):
(base / sub).mkdir(parents=True, exist_ok=True)
def _run_setup() -> None:
if cfg.config_exists():
overwrite = typer.confirm(
@@ -90,6 +97,8 @@ def _run_setup() -> None:
if not overwrite:
raise typer.Abort()
_ensure_data_dirs()
# Ensure the export CLI is present before finishing setup
try:
tools.ensure_export_cli()
@@ -110,6 +119,8 @@ def _run_setup() -> None:
def _start_service(run_now: bool = False) -> None:
global _master_password
_ensure_data_dirs()
# Verify the export CLI is present (offers download if missing)
try:
tools.ensure_export_cli()