summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/handler
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-10-17 09:01:04 -0500
committerLuke Kanies <luke@madstop.com>2008-10-17 09:01:04 -0500
commit8aee40de69e6fe8d67ab58a2e223443b15820584 (patch)
tree89e230df3b43302a542f2cb6869f63e2fb93f6d8 /lib/puppet/network/handler
parent1b517d2fb048603bd1743a662bde74e8ae4b13dc (diff)
parenta74ec60d33dee1c592ec858faeccc23d7a7b79f3 (diff)
downloadpuppet-8aee40de69e6fe8d67ab58a2e223443b15820584.tar.gz
puppet-8aee40de69e6fe8d67ab58a2e223443b15820584.tar.xz
puppet-8aee40de69e6fe8d67ab58a2e223443b15820584.zip
Merge branch '0.24.x' Removed the 'after' blocks that call Type.clear,
since that method is deprecated. Conflicts: CHANGELOG bin/puppetca lib/puppet/file_serving/fileset.rb lib/puppet/network/xmlrpc/client.rb lib/puppet/type/file/selcontext.rb spec/unit/file_serving/metadata.rb spec/unit/type/file.rb
Diffstat (limited to 'lib/puppet/network/handler')
-rwxr-xr-xlib/puppet/network/handler/fileserver.rb84
-rw-r--r--lib/puppet/network/handler/master.rb2
2 files changed, 39 insertions, 47 deletions
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index 14319ef96..160dab1bb 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -70,7 +70,9 @@ class Puppet::Network::Handler
mount.debug("Describing %s for %s" % [url, client]) if client
# use the mount to resolve the path for us.
- metadata = Puppet::FileServing::Metadata.new(url, :path => mount.file_path(path, client), :links => links)
+ return "" unless full_path = mount.file_path(path, client)
+
+ metadata = Puppet::FileServing::Metadata.new(url, :path => full_path, :links => links)
return "" unless metadata.exist?
@@ -654,55 +656,38 @@ class Puppet::Network::Handler
# and "bad batch".
#
def list(relpath, recurse, ignore, client = nil)
- reclist(file_path(relpath, client), nil, recurse, ignore)
- end
-
- # Recursively list the files in this tree.
- def reclist(basepath, abspath, recurse, ignore)
- abspath = basepath if abspath.nil?
- relpath = abspath.sub(%r{^#{basepath}}, '')
- relpath = "/#{relpath}" if relpath[0] != ?/ #/
-
- return unless FileTest.exists?(abspath)
-
- desc = [relpath]
-
- ftype = File.stat(abspath).ftype
-
- desc << ftype
- if recurse.is_a?(Integer)
- recurse -= 1
+ abspath = file_path(relpath, client)
+ if FileTest.exists?(abspath)
+ if FileTest.directory?(abspath) and recurse
+ return reclist(abspath, recurse, ignore)
+ else
+ return [["/", File.stat(abspath).ftype]]
+ end
end
+ return nil
+ end
- ary = [desc]
- if recurse == true or (recurse.is_a?(Integer) and recurse > -1)
- if ftype == "directory"
- children = Dir.entries(abspath)
- if ignore
- children = handleignore(children, abspath, ignore)
- end
- children.each { |child|
- next if child =~ /^\.\.?$/
- reclist(basepath, File.join(abspath, child), recurse, ignore).each { |cobj|
- ary << cobj
- }
- }
+ def reclist(abspath, recurse, ignore)
+ require 'puppet/file_serving'
+ require 'puppet/file_serving/fileset'
+ args = { :recurse => recurse, :links => :follow }
+ args[:ignore] = ignore if ignore
+ fs = Puppet::FileServing::Fileset.new(abspath, args)
+ ary = fs.files.collect do |file|
+ if file == "."
+ file = "/"
+ else
+ file = File.join("/", file )
end
+ stat = fs.stat(File.join(abspath, file))
+ next if stat.nil?
+ [ file, stat.ftype ]
end
return ary.compact
end
- # Deal with ignore parameters.
- def handleignore(files, path, ignore_patterns)
- ignore_patterns.each do |ignore|
- files.delete_if do |entry|
- File.fnmatch(ignore, entry, File::FNM_DOTMATCH)
- end
- end
- return files
- end
- end
+ end
# A special mount class specifically for the plugins mount -- just
# has some magic to effectively do a union mount of the 'plugins'
@@ -730,7 +715,7 @@ class Puppet::Network::Handler
end
def file_path(relpath, client = nil)
- mod = valid_modules.map { |m| mod_path_exists?(m, relpath, client) ? m : nil }.compact.first
+ return nil unless mod = valid_modules.map { |m| mod_path_exists?(m, relpath, client) ? m : nil }.compact.first
mod_file_path(mod, relpath, client)
end
@@ -738,9 +723,16 @@ class Puppet::Network::Handler
def list(relpath, recurse, ignore, client = nil)
result = []
valid_modules.each do |m|
- ary = reclist(mod_file_path(m, relpath, client), nil, recurse, ignore)
- ary = [] if ary.nil?
- result += ary
+ modpath = mod_file_path(m, relpath, client)
+ if FileTest.exists?(modpath)
+ if FileTest.directory?(modpath) and recurse
+ ary = reclist(modpath, recurse, ignore)
+ ary = [] if ary.nil?
+ result += ary
+ else
+ result += [["/", File.stat(modpath).ftype]]
+ end
+ end
end
result
end
diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb
index 05ae7b9a2..71b633a09 100644
--- a/lib/puppet/network/handler/master.rb
+++ b/lib/puppet/network/handler/master.rb
@@ -24,7 +24,7 @@ class Puppet::Network::Handler
# Tell a client whether there's a fresh config for it
def freshness(client = nil, clientip = nil)
# Always force a recompile. Newer clients shouldn't do this (as of April 2008).
- return 0
+ return Time.now.to_i
end
def initialize(hash = {})