[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585

James Turnbull james at lovedthanlost.net
Fri Jan 23 14:21:03 UTC 2009


The following commit has been merged in the master branch:
commit af8c70650b028a70ed50ac6c2bd7f4f00c17ae03
Author: Paul Nasrat <pnasrat at googlemail.com>
Date:   Fri Sep 19 11:41:45 2008 +0100

    Fix metadata class for cases when checksum_type set

diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb
index beecaef..b277955 100644
--- a/lib/puppet/file_serving/metadata.rb
+++ b/lib/puppet/file_serving/metadata.rb
@@ -60,10 +60,10 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::FileBase
 
         case stat.ftype
         when "file":
-            @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, real_path)
+            @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, real_path).to_s
         when "directory": # Always just timestamp the directory.
-            sumtype = @checksum_type.to_s =~ /time/ ? @checksum_type : "ctime"
-            @checksum = ("{%s}" % sumtype) + send("%s_file" % sumtype, path).to_s
+            @checksum_type = "ctime"
+            @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, path).to_s
         when "link":
             @destination = File.readlink(real_path)
         else
diff --git a/spec/unit/file_serving/metadata.rb b/spec/unit/file_serving/metadata.rb
index 9743370..60fcbc3 100755
--- a/spec/unit/file_serving/metadata.rb
+++ b/spec/unit/file_serving/metadata.rb
@@ -99,6 +99,14 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do
             @metadata.checksum.should == "{md5}" + @checksum
         end
 
+        it "should give a mtime checksum when checksum_type is set" do
+            time = Time.now
+            @metadata.checksum_type = "mtime"
+            @metadata.expects(:mtime_file).returns(@time)
+            @metadata.collect_attributes
+            @metadata.checksum.should == "{mtime}" + @time.to_s
+        end
+
         it "should produce tab-separated mode, type, owner, group, and checksum for xmlrpc" do
             @metadata.attributes_with_tabs.should == "#{0755.to_s}\tfile\t10\t20\t{md5}#{@checksum}"
         end
@@ -109,14 +117,22 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do
             @stat.stubs(:ftype).returns("directory")
             @time = Time.now
             @metadata.expects(:ctime_file).returns(@time)
-            @metadata.collect_attributes
         end
 
         it "should only use checksums of type 'ctime' for directories" do
+            @metadata.collect_attributes
+            @metadata.checksum.should == "{ctime}" + @time.to_s
+        end
+
+        it "should only use checksums of type 'ctime' for directories even if checksum_type set" do
+            @metadata.checksum_type = "mtime"
+            @metadata.expects(:mtime_file).never
+            @metadata.collect_attributes
             @metadata.checksum.should == "{ctime}" + @time.to_s
         end
 
         it "should produce tab-separated mode, type, owner, group, and checksum for xmlrpc" do
+            @metadata.collect_attributes
             @metadata.attributes_with_tabs.should == "#{0755.to_s}\tdirectory\t10\t20\t{ctime}#{@time.to_s}"
         end
     end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list