fix: cleanup removing shared resources needed by multiple formulas by ooye-sanket · Pull Request #21358 · Homebrew/brew

@ooye-sanket @MikeMcQuaid

When multiple formulas (e.g., python@3.14 and python@3.13) share the same resource file, the download queue deduplicates downloads but only creates a single symlink for the first formula. This causes brew cleanup to remove the shared resource when cleaning the first formula, breaking subsequent formula upgrades.

The fix tracks all formulas requesting each resource and creates a
separate symlink for each after the download completes. This ensures reference counting works correctly during cleanup - the file in downloads/ will only be removed when ALL symlinks pointing to it are gone.