Signed-off-by: Paul Nasrat <[EMAIL PROTECTED]>
---
 lib/puppet/type/file/checksum.rb |    4 ++++
 spec/unit/type/file.rb           |    8 ++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/lib/puppet/type/file/checksum.rb b/lib/puppet/type/file/checksum.rb
index 3be147c..27edee1 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 fd790d6..552d284 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
-- 
1.5.3.4


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to