Signed-off-by: Luke Kanies <[email protected]>
---
lib/puppet/type/file.rb | 2 +-
spec/unit/type/file.rb | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 55d4ec7..4efd901 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -832,7 +832,7 @@ module Puppet
fail_if_checksum_is_wrong(path, checksum) if validate
File.rename(path, self[:path])
rescue => detail
- self.err "Could not rename tmp %s for replacing: %s" %
[self[:path], detail]
+ fail "Could not rename temporary file %s to %s : %s" %
[path, self[:path], detail]
ensure
# Make sure the created file gets removed
File.unlink(path) if FileTest.exists?(path)
diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb
index 58cd4ad..627cac4 100755
--- a/spec/unit/type/file.rb
+++ b/spec/unit/type/file.rb
@@ -751,4 +751,15 @@ describe Puppet::Type.type(:file) do
file.finish
end
end
+
+ describe "when writing the file" do
+ it "should propagate failures encountered when renaming the temporary
file" do
+ File.stubs(:open)
+
+ File.expects(:rename).raises ArgumentError
+ file = Puppet::Type::File.new(:name => "/my/file", :backup =>
"puppet")
+
+ lambda { file.write("something", :content) }.should
raise_error(Puppet::Error)
+ end
+ end
end
--
1.6.1
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---