Content is now returning the checksum rather than the actual content, and the method of creating the full checksum wasn't correctly handling timestamps, which aren't strings and can't be the right side of a String + call.
I've opened #2064 as a better long-term fix. Signed-off-by: Luke Kanies <[email protected]> --- lib/puppet/type/file/content.rb | 2 +- spec/unit/type/file/content.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletions(-) diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb index a5fe992..f48e601 100755 --- a/lib/puppet/type/file/content.rb +++ b/lib/puppet/type/file/content.rb @@ -105,7 +105,7 @@ module Puppet return nil if stat.ftype == "directory" begin - return "{#{checksum_type}}" + send(checksum_type.to_s + "_file", resource[:path]) + return "{#{checksum_type}}" + send(checksum_type.to_s + "_file", resource[:path]).to_s rescue => detail raise Puppet::Error, "Could not read %s: %s" % [[email protected], detail] end diff --git a/spec/unit/type/file/content.rb b/spec/unit/type/file/content.rb index fd225fa..0529cd3 100755 --- a/spec/unit/type/file/content.rb +++ b/spec/unit/type/file/content.rb @@ -119,6 +119,21 @@ describe content do @content.retrieve.should be_nil end + it "should always return the checksum as a string" do + @content = content.new(:resource => @resource) + @content.stubs(:checksum_type).returns "mtime" + + stat = mock 'stat', :ftype => "file" + @resource.expects(:stat).returns stat + + @resource.expects(:[]).with(:path).returns "/my/file" + + time = Time.now + @content.expects(:mtime_file).with("/my/file").returns time + + @content.retrieve.should == "{mtime}%s" % time + end + it "should return the checksum of the file if it exists and is a normal file" do @content = content.new(:resource => @resource) @content.stubs(:checksum_type).returns "md5" -- 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 -~----------~----~----~----~------~----~------~--~---
