[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.1rc1-141-gcdb2b90
James Turnbull
james at lovedthanlost.net
Mon Aug 16 12:47:44 UTC 2010
The following commit has been merged in the upstream branch:
commit 428683917e4819e294f65511932eb1c9067d8cb8
Author: Nick Lewis <nick at puppetlabs.com>
Date: Wed Jun 16 10:41:38 2010 -0700
[#4001] Added explicit check and error message when creating a file if parent doesn't exist
This was giving the regular File.open error for non-existent parent, resulting
in a message citing the non-existence of the file as the reason ensure can't be
changed from absent to present. Now it properly states that the parent
directory is missing.
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 5bb4be1..2ba047b 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -722,6 +722,13 @@ module Puppet
# Write out the file. Requires the content to be written,
# the property name for logging, and the checksum for validation.
def write(content, property, checksum = nil)
+ parent = File.dirname(self[:path])
+ unless FileTest.exists? parent
+ raise Puppet::Error,
+ "Cannot create %s; parent directory %s does not exist" %
+ [self[:path], parent]
+ end
+
if validate = validate_checksum?
# Use the appropriate checksum type -- md5, md5lite, etc.
sumtype = property(:checksum).checktype
diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb
index b2f1292..6ff3a5b 100755
--- a/spec/unit/type/file.rb
+++ b/spec/unit/type/file.rb
@@ -27,6 +27,12 @@ describe Puppet::Type.type(:file) do
lambda { file.write("something", :content) }.should raise_error(Puppet::Error)
end
+ it "should propagate failures encountered when a parent directory does not exist" do
+ file = Puppet::Type::File.new(:name => "/foo/bar")
+
+ lambda { file.write("something", :content) }.should raise_error(Puppet::Error, "Cannot create /foo/bar; parent directory /foo does not exist")
+ end
+
describe "when validating the checksum" do
before { @file.stubs(:validate_checksum?).returns(true) }
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list