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.
This commit is contained in:
parent
96d32774b9
commit
a6a8306c46
@ -486,10 +486,10 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
|
|||||||
# The cached location is no longer fresh if either:
|
# The cached location is no longer fresh if either:
|
||||||
# - Last-Modified value is newer than the file's timestamp
|
# - Last-Modified value is newer than the file's timestamp
|
||||||
# - Content-Length value is different than the file's size
|
# - Content-Length value is different than the file's size
|
||||||
cached_location_valid = if cached_location_valid
|
if cached_location_valid && !is_redirection
|
||||||
newer_last_modified = last_modified && last_modified > cached_location.mtime
|
newer_last_modified = last_modified && last_modified > cached_location.mtime
|
||||||
different_file_size = file_size&.nonzero? && file_size != cached_location.size
|
different_file_size = file_size&.nonzero? && file_size != cached_location.size
|
||||||
!(newer_last_modified || different_file_size)
|
cached_location_valid = !(newer_last_modified || different_file_size)
|
||||||
end
|
end
|
||||||
|
|
||||||
if cached_location_valid
|
if cached_location_valid
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user