diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-03 02:12:43 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-03 02:12:43 +0000 |
commit | 18320ee5144c76de4d1d2c5c0fa27fd719882991 (patch) | |
tree | b77910e73ff254b00e0c96d0bcbb3df746819c95 /lib | |
parent | 7fd5b6f91c207efe26a4d296a03be82ec2cdb03d (diff) | |
download | puppet-18320ee5144c76de4d1d2c5c0fa27fd719882991.tar.gz puppet-18320ee5144c76de4d1d2c5c0fa27fd719882991.tar.xz puppet-18320ee5144c76de4d1d2c5c0fa27fd719882991.zip |
Adding a "force" parameter in files to fix #242. Currently only used when replacing directories with links, but should probably be used in other places.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1538 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/type/pfile.rb | 4 | ||||
-rw-r--r-- | lib/puppet/type/pfile/target.rb | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index ab990d67b..8a12ee32a 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -296,7 +296,9 @@ module Puppet when String: newfile = file + backup # Just move it, since it's a directory. - if FileTest.exists?(newfile) + if FileTest.directory?(newfile) + raise Puppet::Error, "Will not replace directory backup; use a filebucket" + elsif FileTest.exists?(newfile) begin File.unlink(newfile) rescue => detail diff --git a/lib/puppet/type/pfile/target.rb b/lib/puppet/type/pfile/target.rb index 04f2c986e..4a725d652 100644 --- a/lib/puppet/type/pfile/target.rb +++ b/lib/puppet/type/pfile/target.rb @@ -28,7 +28,12 @@ module Puppet case stat.ftype when "directory": - FileUtils.rmtree(@parent[:path]) + if @parent[:force] == :true + FileUtils.rmtree(@parent[:path]) + else + notice "Not replacing directory with link; use 'force' to override" + return :nochange + end else File.unlink(@parent[:path]) end |