summaryrefslogtreecommitdiff
path: root/tool/downloader.rb
diff options
context:
space:
mode:
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 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|