Skip to content

Commit 15327eb

Browse files
Joshua Sierlesdanielsdeleo
authored andcommitted
[CHEF-301] Directories and files with a dot (.ssh for example) should be copied with the remote_directory resource
1 parent 4d34bfd commit 15327eb

5 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎chef/lib/chef/provider/remote_directory.rb‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ def action_create
3636
super
3737
Chef::Log.debug("Doing a remote recursive directory transfer for #{@new_resource}")
3838

39-
files_to_purge = Set.new Dir[::File.join(@new_resource.path, '**', '*')]
40-
39+
files_to_purge = Set.new(
40+
Dir.glob(::File.join(@new_resource.path, '**', '*'), ::File::FNM_DOTMATCH).select do |name|
41+
name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/
42+
end
43+
)
4144
files_to_transfer.each do |cookbook_file_relative_path|
4245
create_cookbook_file(cookbook_file_relative_path)
4346
files_to_purge.delete(::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I'm a dot file inside a the root remote_directory source dir.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I'm a dot file in a subdirectory inside a dot remote_directory source
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I'm a file in a subdirectory inside a dot remote_directory source
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I'm a dot file in a subdirectory inside a remote_directory source

0 commit comments

Comments
 (0)