summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/transaction.rb1
-rw-r--r--lib/puppet/type/file.rb26
2 files changed, 13 insertions, 14 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 37f51b2e5..54163c521 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -349,6 +349,7 @@ class Transaction
make_parent_child_relationship(resource, [r])
end
rescue Puppet::Resource::Catalog::DuplicateResourceError
+ made.delete(res)
next
end
end
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index f22b19fc3..99f5b96c1 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -513,6 +513,14 @@ module Puppet
@stat = nil
end
+
+ # Configure discovered resources to be purged.
+ def mark_children_for_purging(children)
+ children.each do |name, child|
+ next if child[:source]
+ child[:ensure] = :absent
+ end
+ end
# Create a new file or directory object as a child to the current
# object.
@@ -580,6 +588,10 @@ module Puppet
recurse_remote(children)
end
+ # If we're purging resources, then delete any resource that isn't on the
+ # remote system.
+ mark_children_for_purging(children) if self.purge?
+
return children.values.sort { |a, b| a[:path] <=> b[:path] }
end
@@ -661,20 +673,6 @@ module Puppet
children[meta.relative_path].parameter(:source).metadata = meta
end
- # If we're purging resources, then delete any resource that isn't on the
- # remote system.
- if self.purge?
- # Make a hash of all of the resources we found remotely -- all we need is the
- # fast lookup, the values don't matter.
- remotes = total.inject({}) { |hash, meta| hash[meta.relative_path] = true; hash }
-
- children.each do |name, child|
- unless remotes.include?(name)
- child[:ensure] = :absent
- end
- end
- end
-
children
end