summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2009-11-19 22:11:49 -0800
committerJames Turnbull <james@lovedthanlost.net>2009-11-21 13:35:27 +1100
commit53b3b86681e3c56f8455e5d8458b4ea900a50406 (patch)
tree82b75c5e1672325bb4273fd7b11d3304a1c32383 /lib/puppet
parent8129caabdab73fca8b4b8de0ecafe4c0dd31cc95 (diff)
downloadpuppet-53b3b86681e3c56f8455e5d8458b4ea900a50406.tar.gz
puppet-53b3b86681e3c56f8455e5d8458b4ea900a50406.tar.xz
puppet-53b3b86681e3c56f8455e5d8458b4ea900a50406.zip
Fix for ticket #2844 (file recursion generated vs. explicit prefix)
The routine which was determining if one path was a prefix of another in arbitrating between explicit and generated resources was using the raw string for the test without regard to path segments and thus could be fooled by pairs such as "/tmp/foo" vs. "/tmp/foo2" Fix was to be path delimiter aware and add a test. Signed-off-by: Markus Roberts <Markus@reality.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/type/file.rb26
1 files changed, 9 insertions, 17 deletions
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index f9205255a..a4666a95f 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -496,26 +496,18 @@ module Puppet
# not likely to have many actual conflicts, which is good, because
# this is a pretty inefficient implementation.
def remove_less_specific_files(files)
- # We sort the paths so we can short-circuit some tests.
- mypath = self[:path]
- other_paths = catalog.vertices.find_all do |r|
- r.is_a?(self.class) and r[:path][0..(mypath.length - 1)] == mypath
- end.collect { |r| r[:path] }.sort { |a, b| a.length <=> b.length } - [self[:path]]
+ mypath = self[:path].split(File::Separator)
+ other_paths = catalog.vertices.
+ select { |r| r.is_a?(self.class) and r[:path] != self[:path] }.
+ collect { |r| r[:path].split(File::Separator) }.
+ select { |p| p[0,mypath.length] == mypath }
return files if other_paths.empty?
- remove = []
- files.each do |file|
- path = file[:path]
- other_paths.each do |p|
- if path[0..(p.length - 1)] == p
- remove << file
- break
- end
- end
- end
-
- files - remove
+ files.reject { |file|
+ path = file[:path].split(File::Separator)
+ other_paths.any? { |p| path[0,p.length] == p }
+ }
end
# A simple method for determining whether we should be recursing.