]> git.openstreetmap.org Git - chef.git/blob - cookbooks/chef/libraries/remote_directory.rb
More rubocop cleanup
[chef.git] / cookbooks / chef / libraries / remote_directory.rb
1 class Chef
2   class Provider
3     class RemoteDirectory
4       def action_create
5         super
6         Chef::Log.debug("Doing a remote recursive directory transfer for #{@new_resource}")
7
8         files_transferred = Set.new
9         files_to_transfer.each do |cookbook_file_relative_path|
10           create_cookbook_file(cookbook_file_relative_path)
11           files_transferred << ::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path))
12           files_transferred << ::File.join(@new_resource.path, cookbook_file_relative_path)
13         end
14
15         return unless @new_resource.purge
16
17         files_to_purge = Set.new(
18           Dir.glob(::File.join(@new_resource.path, '**', '*'), ::File::FNM_DOTMATCH).select do |name|
19             name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/
20           end
21         )
22         files_to_purge -= files_transferred
23         purge_unmanaged_files(files_to_purge)
24       end
25     end
26   end
27 end