X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/b17dd01854b7d2dd4caa29ff4e05c03f3ff69890..2d43acf0477a2dbf2efaed7480d0d73454d8196e:/cookbooks/chef/libraries/remote_directory.rb diff --git a/cookbooks/chef/libraries/remote_directory.rb b/cookbooks/chef/libraries/remote_directory.rb index 97adee117..959eb2940 100644 --- a/cookbooks/chef/libraries/remote_directory.rb +++ b/cookbooks/chef/libraries/remote_directory.rb @@ -4,22 +4,23 @@ class Chef def action_create super Chef::Log.debug("Doing a remote recursive directory transfer for #{@new_resource}") - + files_transferred = Set.new files_to_transfer.each do |cookbook_file_relative_path| create_cookbook_file(cookbook_file_relative_path) files_transferred << ::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)) files_transferred << ::File.join(@new_resource.path, cookbook_file_relative_path) end - if @new_resource.purge - files_to_purge = Set.new( - Dir.glob(::File.join(@new_resource.path, '**', '*'), ::File::FNM_DOTMATCH).select do |name| - name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/ - end - ) - files_to_purge = files_to_purge - files_transferred - purge_unmanaged_files(files_to_purge) - end + + return unless @new_resource.purge + + files_to_purge = Set.new( + Dir.glob(::File.join(@new_resource.path, "**", "*"), ::File::FNM_DOTMATCH).select do |name| + name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/ + end + ) + files_to_purge -= files_transferred + purge_unmanaged_files(files_to_purge) end end end