summaryrefslogtreecommitdiff
path: root/tool/downloader.rb
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-20 10:48:52 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-20 10:48:52 +0000
commit10cb4ca0c47d11e5ac32996e1efa4d7668659332 (patch)
tree193a18ab52069efcaec654f59ae6ca2d67be2bb6 /tool/downloader.rb
parentacaafe2101be7bad03197075c7e1626640929c11 (diff)
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
Diffstat (limited to 'tool/downloader.rb')
-rw-r--r--tool/downloader.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/tool/downloader.rb b/tool/downloader.rb
index 71579c5..4466e53 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|