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

ruby-changes:34100

From: akr <ko1@a...>
Date: Tue, 27 May 2014 23:51:21 +0900 (JST)
Subject: [ruby-changes:34100] akr:r46181 (trunk): * lib/cgi/core.rb: Use Tempfile#close(true) instead of Tempfile#unlink

akr	2014-05-27 23:51:08 +0900 (Tue, 27 May 2014)

  New Revision: 46181

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

  Log:
    * lib/cgi/core.rb: Use Tempfile#close(true) instead of Tempfile#unlink
      to close file descriptors.

  Modified files:
    trunk/ChangeLog
    trunk/lib/cgi/core.rb
    trunk/test/cgi/test_cgi_multipart.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46180)
+++ ChangeLog	(revision 46181)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue May 27 23:50:07 2014  Tanaka Akira  <akr@f...>
+
+	* lib/cgi/core.rb: Use Tempfile#close(true) instead of Tempfile#unlink
+	  to close file descriptors.
+
 Tue May 27 23:06:46 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (parser_number_literal_suffix): refine error message for
Index: lib/cgi/core.rb
===================================================================
--- lib/cgi/core.rb	(revision 46180)
+++ lib/cgi/core.rb	(revision 46181)
@@ -550,7 +550,7 @@ class CGI https://github.com/ruby/ruby/blob/trunk/lib/cgi/core.rb#L550
         name = $1 || $2 || ''
         if body.original_filename.empty?
           value=body.read.dup.force_encoding(@accept_charset)
-          body.unlink if defined?(Tempfile) && body.kind_of?(Tempfile)
+          body.close(true) if defined?(Tempfile) && body.kind_of?(Tempfile)
           (params[name] ||= []) << value
           unless value.valid_encoding?
             if @accept_charset_error_block
@@ -578,7 +578,7 @@ class CGI https://github.com/ruby/ruby/blob/trunk/lib/cgi/core.rb#L578
       if tempfiles
         tempfiles.each {|t|
           if t.path
-            t.unlink
+            t.close(true)
           end
         }
       end
Index: test/cgi/test_cgi_multipart.rb
===================================================================
--- test/cgi/test_cgi_multipart.rb	(revision 46180)
+++ test/cgi/test_cgi_multipart.rb	(revision 46181)
@@ -118,7 +118,7 @@ class CGIMultipartTest < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L118
     $stdin.close() if $stdin.is_a?(Tempfile)
     $stdin = STDIN
     @tempfiles.each {|t|
-      t.unlink
+      t.close(true)
     }
   end
 
@@ -179,7 +179,7 @@ class CGIMultipartTest < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L179
       cgi.params.each {|name, vals|
         vals.each {|val|
           if val.kind_of?(Tempfile) && val.path
-            val.unlink
+            val.close(true)
           end
         }
       }
@@ -330,7 +330,7 @@ class CGIMultipartTest < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L330
     cgi = RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new
     assert_equal(cgi['foo'], 'bar')
     assert_equal(cgi['file'].read, 'b'*10134)
-    cgi['file'].unlink if cgi['file'].kind_of? Tempfile
+    cgi['file'].close(true) if cgi['file'].kind_of? Tempfile
   end
 
   def test_cgi_multipart_without_tempfile

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

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