diff options
author | Lamont Granquist <lamont@opscode.com> | 2013-04-09 13:17:51 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@opscode.com> | 2013-04-09 13:17:51 -0700 |
commit | 8ba2ea4bf2211d56acc85f4897cffc8e61cff243 (patch) | |
tree | 0fc07ecb32bdb1f88f09a1cf5ab9d2f53adfbb5c /lib/chef/provider/file.rb | |
parent | da6248b75dea8a27cf3d7bf229e932c2ec1d9999 (diff) | |
download | chef-8ba2ea4bf2211d56acc85f4897cffc8e61cff243.tar.gz |
fix cleaning up non-normal files and provide better messaging
Diffstat (limited to 'lib/chef/provider/file.rb')
-rw-r--r-- | lib/chef/provider/file.rb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb index 1ad9157fdb..98d7e4c393 100644 --- a/lib/chef/provider/file.rb +++ b/lib/chef/provider/file.rb @@ -163,10 +163,31 @@ class Chef end end + def file_type_string(path) + case + when File.blockdev?(path) + "block device" + when File.chardev?(path) + "char device" + when File.directory?(path) + "directory" + when File.pipe?(path) + "pipe" + when File.socket?(path) + "socket" + when File.symlink?(path) + "symlink" + else + "unknown filetype" + end + end + def do_unlink @file_unlinked = false - unless ::File.file?(@new_resource.path) - converge_by("unlink non-normal file at #{@new_resource.path}") do + if ::File.exists?(@new_resource.path) && !::File.file?(@new_resource.path) + # unlink things that aren't normal files + description = "unlink #{file_type_string(@new_resource.path)} at #{@new_resource.path}" + converge_by(description) do ::File.unlink(@new_resource.path) end @file_unlinked = true |