summaryrefslogtreecommitdiffstats
path: root/lib/puppet/file_serving
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2009-12-31 01:04:06 -0800
committerJames Turnbull <james@lovedthanlost.net>2010-01-01 11:24:21 +1100
commit7e64393dd10023d528d2fc21383ead30c9ee94dd (patch)
treebc2fa8b52be1a866df4d3ec0710e5bb7a04d916d /lib/puppet/file_serving
parent7e2e12be7827c2adb64a192b5b7176c7c541af44 (diff)
downloadpuppet-7e64393dd10023d528d2fc21383ead30c9ee94dd.tar.gz
puppet-7e64393dd10023d528d2fc21383ead30c9ee94dd.tar.xz
puppet-7e64393dd10023d528d2fc21383ead30c9ee94dd.zip
Additional fix for #2994 (followed symlinks do not have checksums)
The first patch for #2994, to which this is an extension, exposed the fact that checksums were not being included in the metadata for followed links; checksums are needed for managing the contents of files that are represented on the server as links (links => follow). This patch adds checksums for followed links and tests to confirm that it works as expected.
Diffstat (limited to 'lib/puppet/file_serving')
-rw-r--r--lib/puppet/file_serving/metadata.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb
index 275a090eb..678a4ff42 100644
--- a/lib/puppet/file_serving/metadata.rb
+++ b/lib/puppet/file_serving/metadata.rb
@@ -22,18 +22,15 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
PARAM_ORDER = [:mode, :ftype, :owner, :group]
def attributes_with_tabs
+ raise(ArgumentError, "Cannot manage files of type #{ftype}") unless ['file','directory','link'].include? ftype
desc = []
PARAM_ORDER.each { |check|
check = :ftype if check == :type
desc << send(check)
}
- case ftype
- when "file", "directory"; desc << checksum
- when "link"; desc << @destination
- else
- raise ArgumentError, "Cannot manage files of type %s" % ftype
- end
+ desc << checksum if ftype == 'file' or ftype == 'directory' or (ftype == 'link' and @links == :follow)
+ desc << @destination if ftype == 'link' and @links != :follow
return desc.join("\t")
end
@@ -66,6 +63,7 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
@checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, path).to_s
when "link"
@destination = File.readlink(real_path)
+ @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, real_path).to_s if @links == :follow
else
raise ArgumentError, "Cannot manage files of type %s" % stat.ftype
end