summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/type/pfile.rb22
-rwxr-xr-xlib/puppet/type/pfile/source.rb4
-rwxr-xr-xtest/types/file.rb16
3 files changed, 27 insertions, 15 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index 650c7ad26..93d715f01 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -546,12 +546,15 @@ module Puppet
if child = self.newchild(file, true, options)
# Mark any unmanaged files for removal if purge is set.
# Use the array rather than [] because tidy uses this method, too.
- if @parameters.include?(:purge) and self.purge?
- info "purging %s" % child.ref
- child[:ensure] = :absent
- else
- child[:require] = self
- end
+# if @parameters.include?(:purge) and self.purge?
+# child.info "source: %s" % child.should(:source)
+# unless child.managed?
+# info "purging %s" % child.ref
+# child[:ensure] = :absent
+# end
+# #else
+# #child[:require] = self
+# end
added << child
end
}
@@ -707,6 +710,13 @@ module Puppet
if @states.include?(:source) and ret = self.sourcerecurse(recurse)
children += ret
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?
+ end
+ end
children
end
diff --git a/lib/puppet/type/pfile/source.rb b/lib/puppet/type/pfile/source.rb
index 89a7d1990..7cbd54fe0 100755
--- a/lib/puppet/type/pfile/source.rb
+++ b/lib/puppet/type/pfile/source.rb
@@ -173,7 +173,9 @@ module Puppet
case @stats[:type]
when "directory", "file":
- unless @parent.deleting?
+ if @parent.deleting?
+ p @parent.should(:ensure)
+ else
@parent[:ensure] = @stats[:type]
end
else
diff --git a/test/types/file.rb b/test/types/file.rb
index ff293d2aa..2710c7dc5 100755
--- a/test/types/file.rb
+++ b/test/types/file.rb
@@ -512,9 +512,6 @@ class TestFile < Test::Unit::TestCase
assert(fileobj, "child object was not created")
assert_equal([fileobj], ret, "child object was not returned")
- # check that the file lists us as a dependency
- assert_equal([[:file, dir.title]], fileobj[:require], "dependency was not set up")
-
# And that it inherited our recurse setting
assert_equal(true, fileobj[:recurse], "file did not inherit recurse")
@@ -557,7 +554,6 @@ class TestFile < Test::Unit::TestCase
badobj = @file[bad]
assert(badobj, "did not create bad object")
- assert_equal(:absent, badobj.should(:ensure), "ensure was not set to absent on bad object")
end
def test_recurse
@@ -1568,7 +1564,7 @@ class TestFile < Test::Unit::TestCase
assert_equal("yayness", File.read(path), "Content did not get set correctly")
end
- # Make sure unmanaged files are be purged.
+ # Make sure unmanaged files are purged.
def test_purge
sourcedir = tempfile()
destdir = tempfile()
@@ -1582,7 +1578,11 @@ class TestFile < Test::Unit::TestCase
# this file should get removed
File.open(purgee, "w") { |f| f.puts "footest" }
- lfobj = Puppet::Type.newfile(:title => "localfile", :path => localfile, :content => "rahtest")
+ lfobj = Puppet::Type.newfile(
+ :title => "localfile",
+ :path => localfile,
+ :content => "rahtest"
+ )
destobj = Puppet::Type.newfile(:title => "destdir", :path => destdir,
@@ -1599,8 +1599,8 @@ class TestFile < Test::Unit::TestCase
assert_nothing_raised { destobj[:purge] = true }
assert_apply(comp)
- assert(FileTest.exists?(dsourcefile), "File got purged")
- assert(FileTest.exists?(localfile), "File got purged")
+ assert(FileTest.exists?(dsourcefile), "Source file got purged")
+ assert(FileTest.exists?(localfile), "Local file got purged")
assert(! FileTest.exists?(purgee), "File did not get purged")
end