diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-04-30 17:29:02 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-04-30 17:29:02 +0000 |
commit | 3aafd81fa48d46737f1fe126bb3ff0d99520a180 (patch) | |
tree | fc6a1fc229ee0242cc61d6e72dca5e94e7e1863e /lib/puppet | |
parent | c2bc8481eb2507c2127f5c67f698f85a222acb4a (diff) | |
download | puppet-3aafd81fa48d46737f1fe126bb3ff0d99520a180.tar.gz puppet-3aafd81fa48d46737f1fe126bb3ff0d99520a180.tar.xz puppet-3aafd81fa48d46737f1fe126bb3ff0d99520a180.zip |
Fixing #594 -- Files on the local machine but not remote machine now purge. Note that this introduces a difference in behaviour between recursing locally and recursing remotely.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2436 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/type/pfile.rb | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index 080c5222f..39a298ed9 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -190,7 +190,10 @@ module Puppet 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." + makes sense when recursively managing directories. + + Note that when using ``purge`` with ``source``, Puppet will purge any files + that are not on the remote system." defaultto :false @@ -720,14 +723,22 @@ module Puppet if ret = self.localrecurse(recurse) children += ret end - if @parameters.include?(:source) and ret = self.sourcerecurse(recurse) - children += ret + + # These will be files pulled in by the file source + sourced = false + if @parameters.include?(:source) + ret, sourced = self.sourcerecurse(recurse) + if ret + children += ret + end end # The purge check needs to happen after all of the other recursion. if self.purge? children.each do |child| - child[:ensure] = :absent unless child.managed? + if (sourced and ! sourced.include?(child[:path])) or ! child.managed? + child[:ensure] = :absent + end end end @@ -852,6 +863,10 @@ module Puppet result = [] found = [] + + # Keep track of all the files we found in the source, so we can purge + # appropriately. + sourced = [] @parameters[:source].should.each do |source| sourceobj, path = uri2obj(source) @@ -892,15 +907,16 @@ module Puppet end found << name + sourced << File.join(self[:path], name) self.newchild(name, false, args) }.reject {|c| c.nil? } if self[:sourceselect] == :first - return result + return [result, sourced] end end - return result + return [result, sourced] end # Set the checksum, from another property. There are multiple |