[前][次][番号順一覧][スレッド一覧]

ruby-changes:35972

From: duerst <ko1@a...>
Date: Mon, 20 Oct 2014 19:49:08 +0900 (JST)
Subject: [ruby-changes:35972] duerst:r48053 (trunk): tool/downloader.rb: Make sure we update to latest version

duerst	2014-10-20 19:48:52 +0900 (Mon, 20 Oct 2014)

  New Revision: 48053

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48053

  Log:
    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.

  Modified files:
    trunk/ChangeLog
    trunk/tool/downloader.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48052)
+++ ChangeLog	(revision 48053)
@@ -1,5 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
 Mon Oct 20 19:06:06 2014  Martin Duerst <duerst@i...>
 
+	* 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@i...>
+
 	* lib/unicode_normalize.rb: revert r48046. The s in sIndex
 	  is not hungarian notation. The variable name sIndex is
 	  directly taken from the relevant part of the Unicode
Index: tool/downloader.rb
===================================================================
--- tool/downloader.rb	(revision 48052)
+++ tool/downloader.rb	(revision 48053)
@@ -54,14 +54,14 @@ class Downloader https://github.com/ruby/ruby/blob/trunk/tool/downloader.rb#L54
   #            '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 https://github.com/ruby/ruby/blob/trunk/tool/downloader.rb#L71
         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|

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]