summaryrefslogtreecommitdiffstats
path: root/lib/puppet/file_bucket
diff options
context:
space:
mode:
authorPaul Berry <paul@puppetlabs.com>2011-01-11 13:45:55 -0800
committerPaul Berry <paul@puppetlabs.com>2011-01-12 16:29:28 -0800
commit94d71799f1ee196186bc3a8a5a1b06ef2ae0806e (patch)
tree007f0c32a9c1380acdc90e57f7f29a5541d9d53d /lib/puppet/file_bucket
parent89f56920f26544f7c5aa97785567b193034db151 (diff)
downloadpuppet-94d71799f1ee196186bc3a8a5a1b06ef2ae0806e.tar.gz
puppet-94d71799f1ee196186bc3a8a5a1b06ef2ae0806e.tar.xz
puppet-94d71799f1ee196186bc3a8a5a1b06ef2ae0806e.zip
(#5838) Make file bucket dipper efficient when saving a file that already exists
Before saving to the file bucket, the file bucket dipper now checks to make sure that no file with the given checksum is already present. Paired-with: Jesse Wolfe <jesse@puppetlabs.com>
Diffstat (limited to 'lib/puppet/file_bucket')
-rw-r--r--lib/puppet/file_bucket/dipper.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/puppet/file_bucket/dipper.rb b/lib/puppet/file_bucket/dipper.rb
index b012a8681..f4bef28a8 100644
--- a/lib/puppet/file_bucket/dipper.rb
+++ b/lib/puppet/file_bucket/dipper.rb
@@ -36,7 +36,12 @@ class Puppet::FileBucket::Dipper
file_bucket_file = Puppet::FileBucket::File.new(contents, :bucket_path => @local_path)
dest_path = "#{@rest_path}#{file_bucket_file.name}"
- file_bucket_file.save(dest_path)
+ # Make a HEAD request for the file so that we don't waste time
+ # uploading it if it already exists in the bucket.
+ unless Puppet::FileBucket::File.head("#{@rest_path}#{file_bucket_file.checksum_type}/#{file_bucket_file.checksum_data}")
+ file_bucket_file.save(dest_path)
+ end
+
return file_bucket_file.checksum_data
rescue => detail
puts detail.backtrace if Puppet[:trace]