Skip to content

fix(brew): track exact cache path so cask download bytes update#95

Merged
fullstackjam merged 2 commits into
mainfrom
fix/cask-progress-cache-tracker
May 19, 2026
Merged

fix(brew): track exact cache path so cask download bytes update#95
fullstackjam merged 2 commits into
mainfrom
fix/cask-progress-cache-tracker

Conversation

@fullstackjam
Copy link
Copy Markdown
Collaborator

Summary

  • CacheTracker matched files by substring of the cask name in the brew downloads dir. brew names cached files after the URL's basename, not the cask, so casks like google-chrome (…--googlechrome.dmg) and tencent-meeting (…--TencentMeeting_….dmg) never matched — the per-cask byte counter sat at 0B/<size> for the whole download.
  • Speed/ETA in the header still looked alive because StickyProgress.AddCompletedBytes deliberately carries the EMA speed across casks (internal/ui/progress.go:302), masking the bug.
  • Fix: resolve the exact path via brew --cache --cask <name> and stat both <path> and <path>.incomplete. brew writes the partial to <cached_location>.incomplete and renames on completion — confirmed in Homebrew's abstract_file_download_strategy.rb. Reporting max(size(path), size(path.incomplete)) covers both states.

Test plan

  • go vet ./internal/brew/...
  • go test ./internal/brew/ -run TestCacheTracker (replaced the previous "picks largest matching file" test, which validated the broken substring match, with one that verifies .incomplete is read during download)
  • CI: lint, unit (L1), contract schema (L2), curl|bash smoke, old-cli compat

The CacheTracker matched files by substring of the cask name, but brew
names cached downloads after the URL's basename, not the cask. Casks
like google-chrome (cached as `…--googlechrome.dmg`, no hyphen) and
tencent-meeting (`…--TencentMeeting_….dmg`) never matched, so the head
showed `0B/<size>` for the entire download while StickyProgress's
carried-over EMA made the speed/ETA look alive.

Resolve the exact path via `brew --cache --cask <name>` and stat both
`<path>` and `<path>.incomplete` (brew's documented temporary-file
convention — see Homebrew's abstract_file_download_strategy.rb). Report
the larger size, which covers both downloading and completed states.
@github-actions github-actions Bot added brew Homebrew related tests Tests only labels May 19, 2026
@fullstackjam fullstackjam merged commit 6e0e545 into main May 19, 2026
11 checks passed
@fullstackjam fullstackjam deleted the fix/cask-progress-cache-tracker branch May 19, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

brew Homebrew related tests Tests only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant