diff options
| author | Jesse Wolfe <jes5199@gmail.com> | 2010-03-30 16:33:44 -0700 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | 8f9fc30bb3b992322a553aa7dc0c504af5e44250 (patch) | |
| tree | 858c75522bc018ff65ae5ca5e0e76158ffc433dc | |
| parent | 23ccefe0e8b51af19a0283c0d8eb3de09b6e4c31 (diff) | |
REST FileBucket: REST barfs on relative paths
Force FileBucket to always send absolute (real) paths
| -rw-r--r-- | lib/puppet/application/filebucket.rb | 1 | ||||
| -rw-r--r-- | lib/puppet/file_bucket/dipper.rb | 9 | ||||
| -rwxr-xr-x | spec/unit/file_bucket/dipper.rb | 6 |
3 files changed, 14 insertions, 2 deletions
diff --git a/lib/puppet/application/filebucket.rb b/lib/puppet/application/filebucket.rb index 09aaf2b5d..ed67009aa 100644 --- a/lib/puppet/application/filebucket.rb +++ b/lib/puppet/application/filebucket.rb @@ -72,7 +72,6 @@ Puppet::Application.new(:filebucket) do path = options[:bucket] || Puppet[:bucketdir] @client = Puppet::FileBucket::Dipper.new(:Path => path) else - require 'puppet/network/handler' @client = Puppet::FileBucket::Dipper.new(:Server => Puppet[:server]) end rescue => detail diff --git a/lib/puppet/file_bucket/dipper.rb b/lib/puppet/file_bucket/dipper.rb index b13e590a9..b4a9eb83d 100644 --- a/lib/puppet/file_bucket/dipper.rb +++ b/lib/puppet/file_bucket/dipper.rb @@ -35,7 +35,7 @@ class Puppet::FileBucket::Dipper end contents = ::File.read(file) begin - file_bucket_file = Puppet::FileBucket::File.new(contents, :bucket_path => @local_path, :path => file) + file_bucket_file = Puppet::FileBucket::File.new(contents, :bucket_path => @local_path, :path => absolutize_path(file) ) dest_path = "#{@rest_path}#{file_bucket_file.name}" file_bucket_file.save(dest_path) @@ -91,5 +91,12 @@ class Puppet::FileBucket::Dipper return nil end end + + private + def absolutize_path( path ) + require 'pathname' + Pathname.new(path).realpath + end + end diff --git a/spec/unit/file_bucket/dipper.rb b/spec/unit/file_bucket/dipper.rb index 5d6625103..5ada34e9d 100755 --- a/spec/unit/file_bucket/dipper.rb +++ b/spec/unit/file_bucket/dipper.rb @@ -4,6 +4,12 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/file_bucket/dipper' describe Puppet::FileBucket::Dipper do + before do + ['/my/file'].each do |x| + Puppet::FileBucket::Dipper.any_instance.stubs(:absolutize_path).with(x).returns(x) + end + end + it "should fail in an informative way when there are failures backing up to the server" do File.stubs(:exist?).returns true File.stubs(:read).returns "content" |
