diff options
author | Jesse Wolfe <jes5199@gmail.com> | 2011-01-10 18:30:42 -0800 |
---|---|---|
committer | Paul Berry <paul@puppetlabs.com> | 2011-01-11 11:41:46 -0800 |
commit | a002231f45339da9b152162c2f48126d95e2e246 (patch) | |
tree | cf51e75f954847fda264b561a7a3acdfa5869dda /lib/puppet/indirector | |
parent | e6e88e7df7fa1cbec1400d73cb7ba9428c420be0 (diff) | |
download | puppet-a002231f45339da9b152162c2f48126d95e2e246.tar.gz puppet-a002231f45339da9b152162c2f48126d95e2e246.tar.xz puppet-a002231f45339da9b152162c2f48126d95e2e246.zip |
(#5171) Made filebucket able to perform diffs
It is now possible to ask the filebucket to diff two files using a URL
of the form:
https://puppet/production/file_bucket_file/md5/{first file hash}?diff_with={second file hash}
The returned diff is a string, the output of the "diff" command.
Paired-with: Paul Berry <paul@puppetlabs.com>
Diffstat (limited to 'lib/puppet/indirector')
-rw-r--r-- | lib/puppet/indirector/file_bucket_file/file.rb | 11 | ||||
-rw-r--r-- | lib/puppet/indirector/indirection.rb | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/puppet/indirector/file_bucket_file/file.rb b/lib/puppet/indirector/file_bucket_file/file.rb index 318858aaf..9d9cee793 100644 --- a/lib/puppet/indirector/file_bucket_file/file.rb +++ b/lib/puppet/indirector/file_bucket_file/file.rb @@ -15,7 +15,16 @@ module Puppet::FileBucketFile def find( request ) checksum, path = request_to_checksum_and_path( request ) - find_by_checksum( checksum, request.options ) + file = find_by_checksum( checksum, request.options ) + + if file && request.options[:diff_with] + hash_protocol = sumtype(checksum) + file2 = find_by_checksum( "{#{hash_protocol}}#{request.options[:diff_with]}", request.options ) + raise "could not find diff_with #{request.options[:diff_with]}" unless file2 + return `diff #{path_for(file).inspect}/contents #{path_for(file2).inspect}/contents` + end + + file end def save( request ) diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb index 309eed7b6..a010c4e40 100644 --- a/lib/puppet/indirector/indirection.rb +++ b/lib/puppet/indirector/indirection.rb @@ -191,7 +191,7 @@ class Puppet::Indirector::Indirection # Otherwise, return the result from the terminus, caching if appropriate. if ! request.ignore_terminus? and result = terminus.find(request) - result.expiration ||= self.expiration + result.expiration ||= self.expiration if result.respond_to?(:expiration) if cache? and request.use_cache? Puppet.info "Caching #{self.name} for #{request.key}" cache.save request(:save, result, *args) |