summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYusuke Endoh <[email protected]>2022-07-26 21:23:47 +0900
committergit <[email protected]>2022-08-23 16:52:40 +0900
commit96562a517d3373466ec306b5f821a41f4758d2a6 ()
treef1ceb9c0d16ebf95ed3206008e47ed89ab2f2fdf /lib
parent073f3b7e0ad94657c04573983affb9d66e6bff2c (diff)
[ruby/fileutils] Narrow the scope of ensure
The ensure in postorder_traverse was added for [Bug #6756]. The intention was to try to delete the parent directory if it failed to get the children. (It may be possible to delete the directory if it is empty.) However, the ensure region rescue'ed not only "failure to get children" but also "failure to delete each child". Thus, the following raised Errno::ENOTEMPTY, but we expect it to raise Errno::EACCES. ``` $ mkdir foo $ touch foo/bar $ chmod 555 foo $ ruby -rfileutils -e 'FileUtils.rm_rf("foo")' ``` This changeset narrows the ensure region so that it rescues only "failure to get children". https://.com/ruby/fileutils/commit/ec5d3b84ea
-rw-r--r--lib/fileutils.rb12
1 files changed, 10 insertions, 2 deletions
@@ -2328,13 +2328,21 @@ module FileUtils
def postorder_traverse
if directory?
- entries().each do |ent|
ent.postorder_traverse do |e|
yield e
end
end
end
- ensure
yield self
end