Skip to content

download_strategy: fix caching of :latest downloads #20137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Library/Homebrew/download_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,6 @@ def fetch(timeout: nil)
ohai "Downloading #{url}"

cached_location_valid = cached_location.exist?
v = version
cached_location_valid = false if v.is_a?(Cask::DSL::Version) && v.latest?

resolved_url, _, last_modified, file_size, is_redirection = begin
resolve_url_basename_time_file_size(url, timeout: Utils::Timer.remaining!(end_time))
Expand All @@ -484,7 +482,7 @@ def fetch(timeout: nil)
# The cached location is no longer fresh if either:
# - Last-Modified value is newer than the file's timestamp
# - Content-Length value is different than the file's size
if cached_location_valid && !is_redirection
if cached_location_valid
newer_last_modified = last_modified && last_modified > cached_location.mtime
different_file_size = file_size&.nonzero? && file_size != cached_location.size
cached_location_valid = !(newer_last_modified || different_file_size)
Expand Down