From 052ec1f39ecbcd134a770cab7645a00461a1e172 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 21:10:10 +0000 Subject: [PATCH] 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 --- main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.py b/main.py index 4df075a..4f6d664 100644 --- a/main.py +++ b/main.py @@ -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()