summaryrefslogtreecommitdiffstats
path: root/lib/puppet/file_serving
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2009-10-31 12:13:55 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-11-05 18:56:55 +1100
commitb8470b8064503baea21d43d5c1dcf349bc4daf59 (patch)
treeefea7a9ac5bd5d16665d1c8ac1b4b568dd95799a /lib/puppet/file_serving
parent5b750c225ff0c646341282aa867d92dbe15509cd (diff)
downloadpuppet-b8470b8064503baea21d43d5c1dcf349bc4daf59.tar.gz
puppet-b8470b8064503baea21d43d5c1dcf349bc4daf59.tar.xz
puppet-b8470b8064503baea21d43d5c1dcf349bc4daf59.zip
Fix #2757 & CSR 92 (symlinks in recursively managed dirs)
The fundemental problem was that, despite what the comment said, the early bailout for file content management only applied to directories, not to links. Making links bail out at as well fixed the problem for most users. However, it would still occur for users with mixed ruby version system since there were no to_/from_pson methods for file metadata. So the second (and far larger) part of this patch adds metadata pson support. The testing is unit level only, as there's no pratical way to do the cross-ruby-version acceptance testing and no benifit to doing "integration" testing short of that. Signed-off-by: Markus Roberts <Markus@reductivelabs.com>
Diffstat (limited to 'lib/puppet/file_serving')
-rw-r--r--lib/puppet/file_serving/base.rb15
-rw-r--r--lib/puppet/file_serving/metadata.rb45
2 files changed, 57 insertions, 3 deletions
diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb
index c82bb1992..02132e885 100644
--- a/lib/puppet/file_serving/base.rb
+++ b/lib/puppet/file_serving/base.rb
@@ -74,4 +74,19 @@ class Puppet::FileServing::Base
end
File.send(@stat_method, full_path())
end
+
+ def to_pson_data_hash
+ {
+ # No 'document_type' since we don't send these bare
+ 'data' => {
+ 'path' => @path,
+ 'relative_path' => @relative_path,
+ 'links' => @links
+ },
+ 'metadata' => {
+ 'api_version' => 1
+ }
+ }
+ end
+
end
diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb
index 335dad497..275a090eb 100644
--- a/lib/puppet/file_serving/metadata.rb
+++ b/lib/puppet/file_serving/metadata.rb
@@ -71,8 +71,47 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
end
end
- def initialize(*args)
- @checksum_type = "md5"
- super
+ def initialize(path,data={})
+ @owner = data.delete('owner')
+ @group = data.delete('group')
+ @mode = data.delete('mode')
+ if checksum = data.delete('checksum')
+ @checksum_type = checksum['type']
+ @checksum = checksum['value']
+ end
+ @checksum_type ||= "md5"
+ @ftype = data.delete('type')
+ @destination = data.delete('destination')
+ super(path,data)
+ end
+
+ PSON.register_document_type('FileMetadata',self)
+ def to_pson_data_hash
+ {
+ 'document_type' => 'FileMetadata',
+ 'data' => super['data'].update({
+ 'owner' => owner,
+ 'group' => group,
+ 'mode' => mode,
+ 'checksum' => {
+ 'type' => checksum_type,
+ 'value' => checksum
+ },
+ 'type' => ftype,
+ 'destination' => destination,
+ }),
+ 'metadata' => {
+ 'api_version' => 1
+ }
+ }
+ end
+
+ def to_pson(*args)
+ to_pson_data_hash.to_pson(*args)
+ end
+
+ def self.from_pson(data)
+ new(data.delete('path'), data)
end
+
end