From 9b627cd0e061316feb73f332abb3c1e4e7aefe28 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 27 Apr 2006 16:59:10 +0000 Subject: Trying to track down the bugs reported this morning, so I added some more test cases. I did find a bug in the filebuckets, fixed it, and added a test case. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1143 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet.rb | 2 +- lib/puppet/client/dipper.rb | 2 +- lib/puppet/server/filebucket.rb | 16 ++++++++-------- lib/puppet/type/pfile.rb | 3 +-- lib/puppet/type/pfilebucket.rb | 14 ++++++++++---- 5 files changed, 21 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/puppet.rb b/lib/puppet.rb index 213eb088e..6824c822f 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -14,7 +14,7 @@ require 'puppet/util' # # it's also a place to find top-level commands like 'debug' module Puppet - PUPPETVERSION = '0.16.1' + PUPPETVERSION = '0.16.2' def Puppet.version return PUPPETVERSION diff --git a/lib/puppet/client/dipper.rb b/lib/puppet/client/dipper.rb index bc85236a3..5965c6b7d 100644 --- a/lib/puppet/client/dipper.rb +++ b/lib/puppet/client/dipper.rb @@ -10,7 +10,7 @@ module Puppet def initialize(hash = {}) if hash.include?(:Path) bucket = Puppet::Server::FileBucket.new( - :Bucket => hash[:Path] + :Path => hash[:Path] ) hash.delete(:Path) hash[:Bucket] = bucket diff --git a/lib/puppet/server/filebucket.rb b/lib/puppet/server/filebucket.rb index 8a4d1a0a4..d07fc93af 100755 --- a/lib/puppet/server/filebucket.rb +++ b/lib/puppet/server/filebucket.rb @@ -16,7 +16,7 @@ class Server Puppet.config.setdefaults("filebucket", :bucketdir => { :default => "$vardir/bucket", - :mode => 0770, + :mode => 0750, :owner => "$user", :group => "$group", :desc => "Where FileBucket files are stored." @@ -28,7 +28,7 @@ class Server } Puppet::Util.logmethods(self, true) - attr_reader :name + attr_reader :name, :path # this doesn't work for relative paths def FileBucket.paths(base,md5) @@ -48,19 +48,19 @@ class Server end if hash.include?(:Path) - @bucket = hash[:Path] + @path = hash[:Path] hash.delete(:Path) else if defined? Puppet - @bucket = Puppet[:bucketdir] + @path = Puppet[:bucketdir] else - @bucket = File.expand_path("~/.filebucket") + @path = File.expand_path("~/.filebucket") end end Puppet.config.use(:filebucket) - @name = "filebucket[#{Puppet[:bucketdir]}]" + @name = "filebucket[#{@path}]" end # accept a file from a client @@ -68,7 +68,7 @@ class Server contents = Base64.decode64(string) md5 = Digest::MD5.hexdigest(contents) - bpath, bfile, pathpath = FileBucket.paths(@bucket,md5) + bpath, bfile, pathpath = FileBucket.paths(@path,md5) # if it's a new directory... if Puppet.recmkdir(bpath) @@ -131,7 +131,7 @@ class Server end def getfile(md5, client = nil, clientip = nil) - bpath, bfile, bpaths = FileBucket.paths(@bucket,md5) + bpath, bfile, bpaths = FileBucket.paths(@path,md5) unless FileTest.exists?(bfile) return false diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index a6b8c5a1f..08f003f8c 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -271,8 +271,7 @@ module Puppet end end begin - FileUtils.cp(file, - file + backup) + FileUtils.cp(file, file + backup) return true rescue => detail # since they said they want a backup, let's error out diff --git a/lib/puppet/type/pfilebucket.rb b/lib/puppet/type/pfilebucket.rb index 15c968dcf..c337ffa77 100755 --- a/lib/puppet/type/pfilebucket.rb +++ b/lib/puppet/type/pfilebucket.rb @@ -2,8 +2,6 @@ require 'puppet/server/filebucket' module Puppet newtype(:filebucket) do - attr_reader :bucket - @doc = "A repository for backing up files. If no filebucket is defined, then files will be backed up in their current directory, but the filebucket can be either a host- or site-global repository @@ -42,6 +40,8 @@ module Puppet desc "The path to the local filebucket. If this is not specified, then the bucket is remote and *server* must be specified." + + defaultto { Puppet[:bucketdir] } end # get the actual filebucket object @@ -57,9 +57,15 @@ module Puppet self.collect do |obj| obj.name end end - def initialize(hash) - super + def bucket + unless defined? @bucket + mkbucket() + end + + @bucket + end + def mkbucket if self[:server] begin @bucket = Puppet::Client::Dipper.new( -- cgit