ruby-changes:14273
From: akr <ko1@a...>
Date: Mon, 14 Dec 2009 21:50:28 +0900 (JST)
Subject: [ruby-changes:14273] Ruby:r26098 (trunk): * lib/find.rb (Find.find): narrow rescue region.
akr 2009-12-14 21:50:13 +0900 (Mon, 14 Dec 2009) New Revision: 26098 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26098 Log: * lib/find.rb (Find.find): narrow rescue region. Modified files: trunk/ChangeLog trunk/lib/find.rb trunk/test/test_find.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 26097) +++ ChangeLog (revision 26098) @@ -1,3 +1,7 @@ +Mon Dec 14 21:49:30 2009 Tanaka Akira <akr@f...> + + * lib/find.rb (Find.find): narrow rescue region. + Mon Dec 14 09:20:54 2009 Nobuyoshi Nakada <nobu@r...> * lib/find.rb (Find.find): removed already unnecessary code. Index: lib/find.rb =================================================================== --- lib/find.rb (revision 26097) +++ lib/find.rb (revision 26098) @@ -44,18 +44,19 @@ rescue SystemCallError next end - begin - if s.directory? then + if s.directory? then + begin fs = Dir.entries(file) - fs.sort! - fs.reverse_each {|f| - next if f == "." or f == ".." - f = File.join(file, f) - paths.unshift f.untaint - } - end - rescue Errno::ENOENT, Errno::EACCES - end + rescue Errno::ENOENT, Errno::EACCES + next + end + fs.sort! + fs.reverse_each {|f| + next if f == "." or f == ".." + f = File.join(file, f) + paths.unshift f.untaint + } + end end end end Index: test/test_find.rb =================================================================== --- test/test_find.rb (revision 26097) +++ test/test_find.rb (revision 26098) @@ -127,6 +127,15 @@ } end + def test_dangling_symlink_stat_error + Dir.mktmpdir {|d| + File.symlink("foo", "#{d}/bar") + assert_raise(Errno::ENOENT) { + Find.find(d) {|f| File.stat(f) } + } + } + end + def test_enumerator Dir.mktmpdir {|d| File.open("#{d}/a", "w") -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/