summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-07-23 16:51:22 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-07-25 12:00:02 +1000
commitb3b76dffdd9cd8ed5c3d0230624bf05015bec5b8 (patch)
tree169d9be6b86aa460f1a563c2821874ddb12cc974 /lib/puppet
parent9120712f97c12dad0c743271b4f64cf545319b69 (diff)
downloadpuppet-b3b76dffdd9cd8ed5c3d0230624bf05015bec5b8.tar.gz
puppet-b3b76dffdd9cd8ed5c3d0230624bf05015bec5b8.tar.xz
puppet-b3b76dffdd9cd8ed5c3d0230624bf05015bec5b8.zip
Fixing #2296 - overlapping recursions work again
This fixes the behaviour when you have file recursions that overlap - we again correctly use the most specific information. It's still a bit expensive when you do this, but at least it behaves correctly, and it should be a rare circumstance. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/type/file.rb30
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 4efd901e5..79ab8eb95 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -580,7 +580,35 @@ module Puppet
# remote system.
mark_children_for_purging(children) if self.purge?
- return children.values.sort { |a, b| a[:path] <=> b[:path] }
+ result = children.values.sort { |a, b| a[:path] <=> b[:path] }
+ remove_less_specific_files(result)
+ end
+
+ # This is to fix bug #2296, where two files recurse over the same
+ # set of files. It's a rare case, and when it does happen you're
+ # 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]]
+
+ 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
end
# A simple method for determining whether we should be recursing.