1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
duerst 2014-10-20 10:48:52 +00:00
parent acaafe2101
commit 10cb4ca0c4
2 changed files with 21 additions and 2 deletions

View file

@ -1,3 +1,10 @@
Mon Oct 20 19:06:06 2014 Martin Duerst <duerst@it.aoyama.ac.jp>
* 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.
Mon Oct 20 19:06:06 2014 Martin Duerst <duerst@it.aoyama.ac.jp>
* lib/unicode_normalize.rb: revert r48046. The s in sIndex

View file

@ -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|