From ff18e5592467c4b8fe2cedf48cd8f9332e0eff32 Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 3 Sep 2006 02:37:56 +0000 Subject: Adding support for file purging, as requested in #250. Any unmanaged files in a purge-enabled directory will be removed. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1539 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/type/pfile.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index 8a12ee32a..ec666497d 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -160,6 +160,18 @@ module Puppet defaultto :ignore end + newparam(:purge) do + desc "Whether unmanaged files should be purged. If you have a filebucket + configured the purged files will be uploaded, but if you do not, + this will destroy data. Only use this option for generated + files unless you really know what you are doing. This option only + makes sense when recursively managing directories." + + defaultto :false + + newvalues(:true, :false) + end + autorequire(:file) do cur = [] pary = self[:path].split(File::SEPARATOR) @@ -675,7 +687,14 @@ module Puppet children.each { |file| file = File.basename(file) next if file =~ /^\.\.?$/ # skip . and .. - if child = self.newchild(file, true, :recurse => recurse) + options = {:recurse => recurse} + + if child = self.newchild(file, true, options) + # Mark any unmanaged files for removal if purge is set. + if self[:purge] == :true and child.implicit? + child[:ensure] = :absent + end + unless @children.include?(child) self.push child added.push file -- cgit