summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2014-09-29 18:19:59 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2014-09-29 18:20:40 -0700
commit3b64e97a0e19920e348ff420aeeb4c565493166b (patch)
tree7911903c8389f47bc379d36108c3dc896b119e6b
parent4098cf801f8d991ab163f5ce21b81c7807dde6ff (diff)
downloadchef-3b64e97a0e19920e348ff420aeeb4c565493166b.tar.gz
Remote directory should pass specs
-rw-r--r--lib/chef/provider/remote_directory.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/chef/provider/remote_directory.rb b/lib/chef/provider/remote_directory.rb
index 553eb14ae5..298231277f 100644
--- a/lib/chef/provider/remote_directory.rb
+++ b/lib/chef/provider/remote_directory.rb
@@ -38,19 +38,17 @@ class Chef
super
files_to_purge = Set.new(Dir.glob(::File.join(Chef::Util::PathHelper.escape_glob(@new_resource.path), '**', '*'),
::File::FNM_DOTMATCH).select do |name|
- name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/
- end)
-
+ basename = Pathname.new(name).basename().to_s
+ ['.', '..'].all? {|n| n != basename}
+ end).map! {|i| Chef::Util::PathHelper.cleanpath(i)}
files_to_transfer.each do |cookbook_file_relative_path|
create_cookbook_file(cookbook_file_relative_path)
- # the file is removed from the purge list
- files_to_purge.delete(::File.join(@new_resource.path, cookbook_file_relative_path))
# parent directories are also removed from the purge list
- directories=::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)).split(::File::SEPARATOR)
- for i in 0..directories.length-1
- files_to_purge.delete(::File.join(directories[0..i]))
+ Pathname.new(Chef::Util::PathHelper.cleanpath(::File.join(@new_resource.path, cookbook_file_relative_path))).descend do |d|
+ files_to_purge.delete(d.to_s)
end
end
+
purge_unmanaged_files(files_to_purge)
end