From c0b0975797647ef5cdb19550652d61829a740be2 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 8 Aug 2005 21:42:03 +0000 Subject: adding creation rollback git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@505 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/type/pfile.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) -- cgit