diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-01 00:12:39 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-01 00:12:39 +0000 |
commit | 62ab87309abcbc80d469c68ee210f34f566f42c0 (patch) | |
tree | 83523e94f9d157ebcd94b80f8142734340d8862f | |
parent | c8f38b7fee12eefb2bed00681b4952ac7ad3f14f (diff) | |
download | puppet-62ab87309abcbc80d469c68ee210f34f566f42c0.tar.gz puppet-62ab87309abcbc80d469c68ee210f34f566f42c0.tar.xz puppet-62ab87309abcbc80d469c68ee210f34f566f42c0.zip |
Deleting the file even if a source is specified, as mentioned by Robert Nickel.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2138 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-x | lib/puppet/type/pfile/source.rb | 4 | ||||
-rwxr-xr-x | test/types/file.rb | 26 |
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/puppet/type/pfile/source.rb b/lib/puppet/type/pfile/source.rb index 77f90bc9f..89a7d1990 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": - @parent[:ensure] = @stats[:type] + unless @parent.deleting? + @parent[:ensure] = @stats[:type] + end else self.info @stats.inspect self.err "Cannot use files of type %s as sources" % diff --git a/test/types/file.rb b/test/types/file.rb index d0a44563d..ff293d2aa 100755 --- a/test/types/file.rb +++ b/test/types/file.rb @@ -950,6 +950,32 @@ class TestFile < Test::Unit::TestCase assert_events([], file) end + # Make sure that content gets used before ensure + def test_deletion_beats_source + dest = tempfile() + source = tempfile() + File.open(source, "w") { |f| f.puts "yay" } + + file = nil + assert_nothing_raised { + file = Puppet.type(:file).create( + :name => dest, + :ensure => :absent, + :source => source + ) + } + + file.retrieve + + assert_events([], file) + assert(! FileTest.exists?(dest), "file was copied during deletion") + + # Now create the dest, and make sure it gets deleted + File.open(dest, "w") { |f| f.puts "boo" } + assert_events([:file_removed], file) + assert(! FileTest.exists?(dest), "file was not deleted during deletion") + end + def test_nameandpath path = tempfile() |