summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCrae <jmccrae@chef.io>2021-04-20 13:57:20 -0700
committerJohn McCrae <jmccrae@chef.io>2021-04-20 13:57:20 -0700
commit1e449b492de9d772c6f50c4cf3f4368ed24c140c (patch)
tree2e049f5dd4881ec284c676262504f0410a0bcada
parent40483c3fbd242017050509e96f6d44721ffffb7e (diff)
downloadchef-jfm/cert_update.tar.gz
updated the spec to verify the chef cache directory exists and create as necessaryjfm/cert_update
Signed-off-by: John McCrae <jmccrae@chef.io>
-rw-r--r--lib/chef/resource/windows_certificate.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/chef/resource/windows_certificate.rb b/lib/chef/resource/windows_certificate.rb
index af0bca9bf0..047d8b969f 100644
--- a/lib/chef/resource/windows_certificate.rb
+++ b/lib/chef/resource/windows_certificate.rb
@@ -397,8 +397,11 @@ class Chef
state = uri.is_a?(URI::HTTP) && !uri.host.nil? ? true : false
if state
begin
- output_file = get_file_name(new_resource.source)
- local_path = ::File.join(Chef::Config[:file_cache_path], output_file)
+ output_file_name = get_file_name(new_resource.source)
+ unless Dir.exist?(Chef::Config[:file_cache_path])
+ Dir.mkdir(Chef::Config[:file_cache_path])
+ end
+ local_path = ::File.join(Chef::Config[:file_cache_path], output_file_name)
@local_pfx_path = local_path
::File.open(local_path, "wb") do |file|
file.write URI.open(new_resource.source).read