mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/find.rb (Find.find): narrow rescue region.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4df4a74308
commit
92e9bf7a59
3 changed files with 25 additions and 11 deletions
|
@ -1,3 +1,7 @@
|
|||
Mon Dec 14 21:49:30 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* lib/find.rb (Find.find): narrow rescue region.
|
||||
|
||||
Mon Dec 14 09:20:54 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/find.rb (Find.find): removed already unnecessary code.
|
||||
|
|
23
lib/find.rb
23
lib/find.rb
|
@ -44,18 +44,19 @@ module Find
|
|||
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
|
||||
|
|
|
@ -127,6 +127,15 @@ class TestFind < Test::Unit::TestCase
|
|||
}
|
||||
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")
|
||||
|
|
Loading…
Add table
Reference in a new issue