refactor(uninstall): split scan_applications into phase helpers
The 529-line scan_applications was carrying four logical phases plus its own temp file, spinner subprocess, and INT trap setup. Carve the phases into private helpers and keep scan_applications as the orchestrator that owns the shared temp files, the INT trap (still using `exit 130` so SIGINT terminates the script regardless of which helper is running), the metadata cache lock context, and the empty-result shortcuts between phases. Helpers (underscore-prefixed; they read and write orchestrator locals via bash dynamic scoping, so do not call them outside scan_applications): - _scan_discover_apps: Pass 1 discovery combining the configured app search directories with pkg-receipt non-standard install locations, writing one <path|name|mtime> row per candidate to discovered_file. - _scan_partition_cache: classifies discovered apps into warm rows (written directly to scan_raw_file via the nested use_cached_scan_metadata helper) and cold rows (queued in app_data_tuples for Pass 2). - _scan_resolve_uncached: Pass 2 parallel resolve. Owns the spinner subprocess (spinner_pid is assigned here), fans out workers up to max_parallel, and waits for completion. process_app_metadata is defined as a nested function so worker subshells inherit it. - _scan_finalize_index: merges scan_raw_file with the metadata cache, runs either the awk pipeline or the bash fallback that performs inline metadata fetches, persists the cache snapshot under a lock, sorts the result by epoch, kicks off the deferred background refresh, and echoes the sorted index path on success. Behavior is preserved end to end. The two empty-result early-returns (after partition, after Pass 2) stay in the orchestrator so the cleanup sequence around them is unchanged. Tests: same suite as the batch_uninstall refactor commit (uninstall, uninstall_safety, uninstall_naming_variants, uninstall_remove_file_list, uninstall_scan_bash32, brew_uninstall) - 95/95 pass.
T
Tw93 committed
10365cda08c302ee1e4b789cdc21d6330fd5955e
Parent: bd07c89