diff options
author | Luke Kanies <luke@madstop.com> | 2005-08-08 21:42:03 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-08-08 21:42:03 +0000 |
commit | c0b0975797647ef5cdb19550652d61829a740be2 (patch) | |
tree | 645e31935a6ba481f8588917c0c9c51fcef053e6 | |
parent | f654f2d26d32bfec7236e360e91d672f190115dd (diff) | |
download | puppet-c0b0975797647ef5cdb19550652d61829a740be2.tar.gz puppet-c0b0975797647ef5cdb19550652d61829a740be2.tar.xz puppet-c0b0975797647ef5cdb19550652d61829a740be2.zip |
adding creation rollback
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@505 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/type/pfile.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index c6f37724a..e5263a2d8 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -28,6 +28,9 @@ module Puppet @should = "file" when "directory", /^d/: @should = "directory" + when "-1", -1: + # this is where a creation is being rolled back + @should = -1 else error = Puppet::Error.new "Cannot create files of type %s" % value @@ -71,6 +74,15 @@ module Puppet Dir.mkdir(@parent.name) end event = :directory_created + when -1: + # this is where the file should be deleted... + unless FileTest.size(@parent.name) == 0 + raise Puppet::Error.new( + "Created file %s has since been modified; cannot roll back." + ) + end + + File.unlink(@parent.name) else error = Puppet::Error.new( "Somehow got told to create a %s file" % @should) |