summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2025-07-03 13:29:32 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2025-07-03 14:29:48 +0900
commit5817e58a60354050cfa059ec8e89202b6e9598d4 (patch)
tree68bb1ae3417216653495ef77c19e257fcfca3ccd
parent319062e4a0608c474e9c934fc4a1171ea2aa1269 (diff)
Extract last-modified time after fetch completes
-rw-r--r--tool/downloader.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/tool/downloader.rb b/tool/downloader.rb
index b5ca416ac5..14f18747f3 100644
--- a/tool/downloader.rb
+++ b/tool/downloader.rb
@@ -191,13 +191,7 @@ class Downloader
mtime = nil
options = options.merge(http_options(file, since.nil? ? true : since))
begin
- data = with_retry(10) do
- data = url.read(options)
- if mtime = data.meta["last-modified"]
- mtime = Time.httpdate(mtime)
- end
- data
- end
+ data = with_retry(10) {url.read(options)}
rescue OpenURI::HTTPError => http_error
case http_error.message
when /^304 / # 304 Not Modified
@@ -225,6 +219,10 @@ class Downloader
return file.to_path
end
raise
+ else
+ if mtime = data.meta["last-modified"]
+ mtime = Time.httpdate(mtime)
+ end
end
dest = (cache_save && cache && !cache.exist? ? cache : file)
dest.parent.mkpath