diff options
| author | Paul Nasrat <pnasrat@googlemail.com> | 2008-09-25 16:05:57 +0100 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2008-09-30 22:23:08 +1000 |
| commit | e6698c2b8624fe2c2bbeef594318e3e8d932d345 (patch) | |
| tree | 7e3037cb6901bd252e6afe3b75dd97895d7306e8 | |
| parent | af8c70650b028a70ed50ac6c2bd7f4f00c17ae03 (diff) | |
| download | puppet-e6698c2b8624fe2c2bbeef594318e3e8d932d345.tar.gz puppet-e6698c2b8624fe2c2bbeef594318e3e8d932d345.tar.xz puppet-e6698c2b8624fe2c2bbeef594318e3e8d932d345.zip | |
Add warning and forcibly set to :md5 fixing #1564
| -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 |
