Signed-off-by: Paul Nasrat <[EMAIL PROTECTED]>
---
lib/puppet/file_serving/metadata.rb | 6 +++---
spec/unit/file_serving/metadata.rb | 18 +++++++++++++++++-
2 files changed, 20 insertions(+), 4 deletions(-)
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 == "[EMAIL PROTECTED]"
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 == "[EMAIL PROTECTED]"
end
end
--
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
-~----------~----~----~----~------~----~------~--~---