Skip to content

fix(upgrade): sync state, deduplicate casks, and auto-repair on errors#22

Open
jhult wants to merge 3 commits into
neul-labs:mainfrom
jhult:fix/upgrades
Open

fix(upgrade): sync state, deduplicate casks, and auto-repair on errors#22
jhult wants to merge 3 commits into
neul-labs:mainfrom
jhult:fix/upgrades

Conversation

@jhult
Copy link
Copy Markdown
Contributor

@jhult jhult commented May 30, 2026

Three changes to make upgrade more reliable:

  • Sync state upfront — reconcile state with the Cellar before upgrading, preventing drift from stale state entries.
  • Deduplicate casks — remove duplicate cask upgrade detection so each cask is upgraded exactly once.
  • Auto-repair on errors — when extraction, linking, or placeholder relocation fails, the affected packages are automatically scanned and fixed (placeholders re-relocated, code signatures re-signed, corrupted packages reinstalled). This is powered by a shared fix_upgrade_issues() function in doctor that also eliminates redundant scanning when running doctor --fix directly.

jhult added 2 commits May 23, 2026 13:36
Upgrade now reconciles state with the Cellar at the start, before any package upgrades occur. This removes orphaned entries for packages no longer on disk, preventing state drift from accumulating across multiple upgrade cycles. State is synced explicitly and the cleanup is reported to the user, ensuring the upgrade begins with authoritative state rather than potentially stale data.
@jhult jhult force-pushed the fix/upgrades branch 2 times, most recently from d625954 to 40f071f Compare May 31, 2026 16:46
Extract Mach-O file discovery, placeholder scanning, and code signature checking/fixing into shared functions so both doctor and upgrade use the same code paths. The new fix_upgrade_issues() entry point accepts a should_fix flag and optional package list, letting callers scan only or apply fixes.

The doctor run() function now delegates to fix_upgrade_issues() instead of inlining WalkDir loops for placeholders and signatures. This eliminates redundant scanning (signatures were previously checked twice) and removes the rayon dependency.

On the upgrade side, errors are printed inline as they occur instead of being collected into a vector for summary display. After all packages are processed, fix_upgrade_issues() runs automatically on affected packages to repair placeholders and code signatures. Error tracking switches from a Vec<(String, String)> to a boolean and an affected package list.

Also adds Database::open_readonly() for opening source databases without applying the local schema and uses it in the cask index sync path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant