diff --git a/ChangeLog b/ChangeLog index b721fb7a12..ecdf5db9bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Oct 20 19:06:06 2014 Martin Duerst + + * 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 * lib/unicode_normalize.rb: revert r48046. The s in sIndex 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|