Skip to content

Commit a6a8306

Browse files
committed
fix: Don't invalidate the cached location if the response is a redirect
A bug introduced with #19460 is that if a redirection has a file size (for example, if it is a 302 that also has HTML content), Homebrew will invalidate the cached location.
1 parent 96d3277 commit a6a8306

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Library/Homebrew/download_strategy.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,10 @@ def fetch(timeout: nil)
486486
# The cached location is no longer fresh if either:
487487
# - Last-Modified value is newer than the file's timestamp
488488
# - Content-Length value is different than the file's size
489-
cached_location_valid = if cached_location_valid
489+
if cached_location_valid && !is_redirection
490490
newer_last_modified = last_modified && last_modified > cached_location.mtime
491491
different_file_size = file_size&.nonzero? && file_size != cached_location.size
492-
!(newer_last_modified || different_file_size)
492+
cached_location_valid = !(newer_last_modified || different_file_size)
493493
end
494494

495495
if cached_location_valid

0 commit comments

Comments
 (0)