diff options
| -rw-r--r-- | CHANGELOG | 2 | ||||
| -rwxr-xr-x | lib/puppet/type/file/checksum.rb | 4 | ||||
| -rwxr-xr-x | spec/unit/type/file.rb | 8 |
3 files changed, 14 insertions, 0 deletions
@@ -1,4 +1,6 @@ 0.24.x + Fixed #1564 - Saving File#checksum to state.yaml broken + Fixed #1603 - Added support for running Puppet inside a Rack application (mod_rails) with Passenger and Apache diff --git a/lib/puppet/type/file/checksum.rb b/lib/puppet/type/file/checksum.rb index 3be147cb7..27edee13d 100755 --- a/lib/puppet/type/file/checksum.rb +++ b/lib/puppet/type/file/checksum.rb @@ -53,6 +53,9 @@ Puppet::Type.type(:file).newproperty(:checksum) do else if FileTest.directory?(@resource[:path]) return :time + elsif @resource[:source] + self.warning("Files with source set must use md5 as checksum. Forcing to md5 from %s for %s" % [ value, @resource[:path] ]) + return :md5 else return symbolize(value) end @@ -161,6 +164,7 @@ Puppet::Type.type(:file).newproperty(:checksum) do checktype = :mtime if checktype == :timestamp checktype = :ctime if checktype == :time + self.should = checktype = :md5 if @resource.property(:source) file ||= @resource[:path] diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb index fd790d678..552d284a7 100755 --- a/spec/unit/type/file.rb +++ b/spec/unit/type/file.rb @@ -41,6 +41,14 @@ describe Puppet::Type.type(:file) do lambda { @file.retrieve }.should raise_error(Puppet::Error) end + it "should always have a checksum type of md5" do + File.open(@path, "w") do |f| f.puts "foo" end + @file[:checksum] = :mtime + @file.property(:checksum).checktype.should == :md5 + @file.property(:checksum).retrieve.should == "{md5}d3b07384d113edec49eaa6238ad5ff00" + @file.property(:checksum).getsum(:mtime).should == "{md5}d3b07384d113edec49eaa6238ad5ff00" + end + end describe "when retrieving remote files" do |
