fix(brew): track exact cache path so cask download bytes update#95
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CacheTrackermatched 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 likegoogle-chrome(…--googlechrome.dmg) andtencent-meeting(…--TencentMeeting_….dmg) never matched — the per-cask byte counter sat at0B/<size>for the whole download.StickyProgress.AddCompletedBytesdeliberately carries the EMA speed across casks (internal/ui/progress.go:302), masking the bug.brew --cache --cask <name>and stat both<path>and<path>.incomplete. brew writes the partial to<cached_location>.incompleteand renames on completion — confirmed in Homebrew'sabstract_file_download_strategy.rb. Reportingmax(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.incompleteis read during download)