Skip to content

Commit 5817e58

Browse files
committed
Extract last-modified time after fetch completes
1 parent 319062e commit 5817e58

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

tool/downloader.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,7 @@ def self.download(url, name, dir = nil, since = true,
191191
mtime = nil
192192
options = options.merge(http_options(file, since.nil? ? true : since))
193193
begin
194-
data = with_retry(10) do
195-
data = url.read(options)
196-
if mtime = data.meta["last-modified"]
197-
mtime = Time.httpdate(mtime)
198-
end
199-
data
200-
end
194+
data = with_retry(10) {url.read(options)}
201195
rescue OpenURI::HTTPError => http_error
202196
case http_error.message
203197
when /^304 / # 304 Not Modified
@@ -225,6 +219,10 @@ def self.download(url, name, dir = nil, since = true,
225219
return file.to_path
226220
end
227221
raise
222+
else
223+
if mtime = data.meta["last-modified"]
224+
mtime = Time.httpdate(mtime)
225+
end
228226
end
229227
dest = (cache_save && cache && !cache.exist? ? cache : file)
230228
dest.parent.mkpath

0 commit comments

Comments
 (0)