From 0badc06550ed2e46c7c4b9f83db755737ffc0412 Mon Sep 17 00:00:00 2001 From: historia Date: Tue, 25 Aug 2026 13:38:33 -0400 Subject: fix: detect if all audio.cpp models already downloaded --- app/backends/audiocpp.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'app/backends/audiocpp.py') diff --git a/app/backends/audiocpp.py b/app/backends/audiocpp.py index 0b82a4e..b950ac6 100755 --- a/app/backends/audiocpp.py +++ b/app/backends/audiocpp.py @@ -859,17 +859,23 @@ def _manager_supports_progress(manager: Path) -> bool: def _decide_download(audiocpp_dir: Path, + model_entries: List[dict], confirm: Callable[[str, bool], bool]) -> bool: """Ask whether to download the selected models now. CONFIRM asks the yes/no question (ask_bool for the line prompts, a TUI confirm for the wizard). When the audio.cpp model manager is missing the prompt is skipped and False is returned, so the install commands are only - printed rather than offered to run. + printed rather than offered to run. The prompt is also skipped (False) + when every selected model is already on disk (see ``_all_models_present``), + so an already-configured checkout is not asked to re-download models it + already has. """ manager = audiocpp_dir / "tools" / "model_manager_v2.py" if not manager.is_file(): return False + if _all_models_present(audiocpp_dir, model_entries): + return False return confirm( "Automatically download the selected models with model_manager_v2.py " "now?", True) @@ -1319,7 +1325,8 @@ def _wizard(stdscr, args: argparse.Namespace, parser: argparse.ArgumentParser def screen_download(): # Automatic model download (or print the install commands). try: - s["download"] = _decide_download(s["audiocpp_dir"], ask_confirm) + s["download"] = _decide_download( + s["audiocpp_dir"], s["model_entries"], ask_confirm) except _GoBack: return tui.Wizard.BACK return _finalize() @@ -1428,6 +1435,26 @@ def _model_path_present(path: Path) -> bool: return False +def _all_models_present(audiocpp_dir: Path, model_entries: List[dict]) -> bool: + """True when every selected model entry's path already holds files on disk. + + Paths resolve against AUDIOCPP_DIR (where model_manager_v2.py installs + them), honoring absolute paths. Used by the wizard to skip the + "Automatically download the selected models" prompt when nothing is + actually missing. An empty selection is treated as not-present. + """ + if not model_entries: + return False + for entry in model_entries: + rel = entry.get("path") + if not isinstance(rel, str) or not rel: + return False + path = Path(rel) if Path(rel).is_absolute() else audiocpp_dir / rel + if not _model_path_present(path): + return False + return True + + def missing_model_entries(server_json: Path) -> List[dict]: """Return the server.json model entries whose files are not on disk. -- cgit v1.2.3