This project is closed and read-only.
Bug #3178 ยป catch_not_deleted_dirs_fileutils_rmdir.patch
| lib/fileutils.rb (working copy) | ||
|---|---|---|
|
parents = options[:parents]
|
||
|
fu_output_message "rmdir #{parents ? '-p ' : ''}#{list.join ' '}" if options[:verbose]
|
||
|
return if options[:noop]
|
||
|
not_deleted_dirs = {}
|
||
|
list.each do |dir|
|
||
|
begin
|
||
|
Dir.rmdir(dir = remove_tailing_slash(dir))
|
||
| ... | ... | |
|
Dir.rmdir(dir)
|
||
|
end
|
||
|
end
|
||
|
rescue Errno::ENOTEMPTY, Errno::ENOENT
|
||
|
rescue Errno::ENOTEMPTY, Errno::ENOENT => errno
|
||
|
not_deleted_dirs[dir] = errno
|
||
|
end
|
||
|
end
|
||
|
not_deleted_dirs
|
||
|
end
|
||
|
module_function :rmdir
|
||
| test/fileutils/test_fileutils.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
subdir = 'data/sub/dir'
|
||
|
mkdir_p(subdir)
|
||
|
assert_nothing_raised(Errno::ENOENT) {
|
||
|
rmdir(subdir, parents: true)
|
||
|
}
|
||
|
dir = 'dir1'
|
||
|
not_exist_dir = 'doesnotexist'
|
||
|
mkdir_p subdir
|
||
|
mkdir_p dir
|
||
|
not_deleted_dirs = rmdir([subdir, dir, not_exist_dir], parents: true)
|
||
|
assert_file_not_exist(subdir)
|
||
|
assert_file_not_exist('data/sub')
|
||
|
assert_directory('data')
|
||
|
assert(not_deleted_dirs['data'].message =~ /Directory not empty/)
|
||
|
assert_equal(not_deleted_dirs['data'].class, Errno::ENOTEMPTY)
|
||
|
assert(not_deleted_dirs[not_exist_dir].message =~ /No such file or directory/)
|
||
|
assert_equal(not_deleted_dirs[not_exist_dir].class, Errno::ENOENT)
|
||
|
assert_equal(not_deleted_dirs.length, 2)
|
||
|
end
|
||
|
def test_rmtree
|
||