X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/ff044920428608b2c04507ad52d6ab52c9d6555f..a6a29b80186ece7013cc283172cc56ca93e8cf67:/cookbooks/chef/libraries/remote_directory.rb diff --git a/cookbooks/chef/libraries/remote_directory.rb b/cookbooks/chef/libraries/remote_directory.rb index 32dacc500..959eb2940 100644 --- a/cookbooks/chef/libraries/remote_directory.rb +++ b/cookbooks/chef/libraries/remote_directory.rb @@ -11,15 +11,16 @@ class Chef 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