Skip to content

Commit 73192af

Browse files
Nuo Yandanielsdeleo
authored andcommitted
use the monkey patched dir (instead of single gsubs) to fix the read file from path specified in Chef::Config entry problem (if backslash is in the path)
1 parent 0cdea3e commit 73192af

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

‎chef/lib/chef/file_cache.rb‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,8 @@ def delete(path)
148148
def list()
149149
keys = Array.new
150150
Dir[File.join(Chef::Config[:file_cache_path], '**', '*')].each do |f|
151-
if File.file?(f)
152-
Chef::Config[:file_cache_path].gsub!(/\\/, "/")
153-
path = f.match("^#{Chef::Config[:file_cache_path]}\/(.+)")[1]
151+
if File.file?(f)
152+
path = f.match("^#{Dir[Chef::Config[:file_cache_path]].first}\/(.+)")[1]
154153
keys << path
155154
end
156155
end

‎chef/lib/chef/provider/file.rb‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ def octal_mode(mode)
4646

4747
def load_current_resource
4848
@current_resource = Chef::Resource::File.new(@new_resource.name)
49-
@current_resource.path(@new_resource.path)
49+
@current_resource.path(Dir[@new_resource.path].first)
5050
if ::File.exist?(@current_resource.path) && ::File.readable?(@current_resource.path)
5151
cstats = ::File.stat(@current_resource.path)
5252
@current_resource.owner(cstats.uid)
5353
@current_resource.group(cstats.gid)
5454
@current_resource.mode(octal_mode(cstats.mode))
55-
@current_resource.path.gsub!(/\\/, "/") #for windows
5655
@current_resource.checksum(checksum(@current_resource.path))
5756
end
5857
@current_resource

0 commit comments

Comments
 (0)