diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-07-03 13:29:32 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-07-03 14:29:48 +0900 |
| commit | 5817e58a60354050cfa059ec8e89202b6e9598d4 (patch) | |
| tree | 68bb1ae3417216653495ef77c19e257fcfca3ccd | |
| parent | 319062e4a0608c474e9c934fc4a1171ea2aa1269 (diff) | |
Extract last-modified time after fetch completes
| -rw-r--r-- | tool/downloader.rb | 12 |
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 |
