diff options
author | Adam Jacob <adam@hjksolutions.com> | 2008-08-16 23:48:44 -0700 |
---|---|---|
committer | Adam Jacob <adam@hjksolutions.com> | 2008-08-16 23:48:44 -0700 |
commit | 1baf929ee98799747cedc275e511bf445792e77a (patch) | |
tree | e72487c29940a222a740db1c0b2b62b6d4c15747 /lib/chef/provider/directory.rb | |
parent | cbfa29a274c1defe36c218d12b70b70e640f7069 (diff) | |
download | chef-1baf929ee98799747cedc275e511bf445792e77a.tar.gz |
Adding remote_file and remote_directory support
Diffstat (limited to 'lib/chef/provider/directory.rb')
-rw-r--r-- | lib/chef/provider/directory.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/chef/provider/directory.rb b/lib/chef/provider/directory.rb index 34257504fc..d042b6a8eb 100644 --- a/lib/chef/provider/directory.rb +++ b/lib/chef/provider/directory.rb @@ -17,6 +17,7 @@ # require File.join(File.dirname(__FILE__), "file") +require "fileutils" class Chef class Provider @@ -36,7 +37,11 @@ class Chef def action_create unless ::File.exists?(@new_resource.path) Chef::Log.info("Creating #{@new_resource} at #{@new_resource.path}") - ::Dir.mkdir(@new_resource.path) + if @new_resource.recursive == true + ::FileUtils.mkdir_p(@new_resource.path) + else + ::Dir.mkdir(@new_resource.path) + end @new_resource.updated = true end set_owner if @new_resource.owner != nil @@ -46,8 +51,13 @@ class Chef def action_delete if ::File.exists?(@new_resource.path) && ::File.writable?(@new_resource.path) - Chef::Log.info("Deleting #{@new_resource} at #{@new_resource.path}") - ::Dir.delete(@new_resource.path) + if @new_resource.recursive == true + Chef::Log.info("Deleting #{@new_resource} recursively at #{@new_resource.path}") + FileUtils.rm_rf(@new_resource.path) + else + Chef::Log.info("Deleting #{@new_resource} at #{@new_resource.path}") + ::Dir.delete(@new_resource.path) + end @new_resource.updated = true else raise RuntimeError, "Cannot delete #{@new_resource} at #{@new_resource_path}!" if ::File.exists?(@new_resource.path) |