From 10cb4ca0c47d11e5ac32996e1efa4d7668659332 Mon Sep 17 00:00:00 2001 From: duerst Date: Mon, 20 Oct 2014 10:48:52 +0000 Subject: tool/downloader.rb: Make sure we update to latest version if network connection is available, but we don't fail if there is no network connection but option -e is set and we already have a version of the file. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/downloader.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'tool/downloader.rb') diff --git a/tool/downloader.rb b/tool/downloader.rb index 71579c536a..4466e53fb9 100644 --- a/tool/downloader.rb +++ b/tool/downloader.rb @@ -54,14 +54,14 @@ class Downloader # 'UnicodeData.txt', 'enc/unicode/data' def self.download(url, name, dir = nil, ims = true) file = dir ? File.join(dir, name) : name - return true if ims.nil? and File.exist?(file) + # return true if ims.nil? and File.exist?(file) url = URI(url) if $VERBOSE $stdout.print "downloading #{name} ... " $stdout.flush end begin - data = url.read(http_options(file, ims)) + data = url.read(http_options(file, ims.nil? ? true : ims)) rescue OpenURI::HTTPError => http_error if http_error.message =~ /^304 / # 304 Not Modified if $VERBOSE @@ -71,6 +71,18 @@ class Downloader return true end raise + rescue Timeout::Error + if ims.nil? and File.exist?(file) + puts "Request for #{url} timed out, using old version." + return true + end + raise + rescue SocketError + if ims.nil? and File.exist?(file) + puts "No network connection, unable to download #{url}, using old version." + return true + end + raise end mtime = nil open(file, "wb", 0600) do |f| -- cgit v1.2.3