summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-12-11 11:14:19 -0600
committerLuke Kanies <luke@madstop.com>2007-12-11 11:14:19 -0600
commit6db18cc3047de4a0495888f6d2accaf937523e94 (patch)
treeda1117930fe36b1d495603a0111b443c44b642b6
parentb19a0c9d23ed3965edaf0b7d75f2eb6d535455f0 (diff)
parent072b03eb000c64eeb54e57ab5ac10c1243cbf1d1 (diff)
downloadpuppet-6db18cc3047de4a0495888f6d2accaf937523e94.tar.gz
puppet-6db18cc3047de4a0495888f6d2accaf937523e94.tar.xz
puppet-6db18cc3047de4a0495888f6d2accaf937523e94.zip
Merge commit 'davids-bugfixes/rest/fix-plugins-mount'
-rwxr-xr-xlib/puppet/network/handler/fileserver.rb65
1 files changed, 22 insertions, 43 deletions
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index da02a46c5..615306883 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -736,6 +736,8 @@ class Puppet::Network::Handler
relpath = abspath.sub(%r{^#{basepath}}, '')
relpath = "/#{relpath}" if relpath[0] != ?/ #/
+ return unless FileTest.exists?(abspath)
+
desc = [relpath]
ftype = File.stat(abspath).ftype
@@ -784,59 +786,36 @@ class Puppet::Network::Handler
''
end
+ def mod_path_exists?(mod, relpath, client = nil)
+ File.exists?(File.join(mod, PLUGINS, relpath))
+ end
+
def path_exists?(relpath, client = nil)
- !valid_modules.find { |m| File.exists?(File.join(m, PLUGINS, relpath)) }.nil?
+ !valid_modules.find { |m| mod_path_exists?(m, relpath, client) }.nil?
end
-
+
def valid?
true
end
- def file_path(relpath, client = nil)
- mod = valid_modules.map { |m| File.exists?(File.join(m, PLUGINS, relpath)) ? m : nil }.compact.first
+ def mod_file_path(mod, relpath, client = nil)
File.join(mod, PLUGINS, relpath)
end
+
+ def file_path(relpath, client = nil)
+ mod = valid_modules.map { |m| mod_path_exists?(m, relpath, client) ? m : nil }.compact.first
+ mod_file_path(mod, relpath, client)
+ end
- def reclist(basepath, abspath, recurse, ignore)
- abspath = basepath if abspath.nil?
- relpath = abspath.sub(%r{^#{basepath}}, '')
- relpath = "/#{relpath}" unless relpath[0] == ?/ #/
-
- desc = [relpath]
-
- ftype = File.stat(file_path(abspath)).ftype
-
- desc << ftype
- if recurse.is_a?(Integer)
- recurse -= 1
- end
-
- ary = [desc]
- if recurse == true or (recurse.is_a?(Integer) and recurse > -1)
- if ftype == "directory"
- valid_modules.each do |mod|
- begin
- children = Dir.entries(File.join(mod, PLUGINS, 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
- }
- }
- rescue Errno::ENOENT
- # A missing directory or whatever isn't a
- # massive problem in here; it'll happen
- # whenever we've got a module that doesn't
- # have a directory than another module does.
- end
- end
- end
+ # create a list of files by merging all modules
+ 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
end
-
- return ary.compact
+ result
end
private