summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authortyler-ball <tball@chef.io>2018-08-03 13:10:25 -0600
committertyler-ball <tball@chef.io>2018-08-03 13:15:09 -0600
commit94f7cb14306f074a3b84ba28f25308968ff6e423 (patch)
tree4897fa4dff70ed93d0de89873c741f268a3770f9 /lib
parent628b6189201c532ae0e3ff962b324018911ff389 (diff)
downloadchef-94f7cb14306f074a3b84ba28f25308968ff6e423.tar.gz
[SHACK-290] Unpacking tarball paths suffer from URI error
Original error: https://github.com/chef/chef-apply/pull/9 I thought I fixed this in https://github.com/chef/chef/pull/7223 but it turns out relative or absolute paths continue to match the URI regular expression. This means that Windows continues to fail to unpack policyfile tarballs. Reversing the order of these checks ensures that real paths do not fall prey to the URI error. Signed-off-by: tyler-ball <tball@chef.io>
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/application/client.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 7bea2bd845..0e5584ded3 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -534,14 +534,14 @@ class Chef::Application::Client < Chef::Application
def fetch_recipe_tarball(url, path)
Chef::Log.trace("Download recipes tarball from #{url} to #{path}")
- if url =~ URI.regexp
+ if File.exist?(url)
+ FileUtils.cp(url, path)
+ elsif url =~ URI.regexp
File.open(path, "wb") do |f|
open(url) do |r|
f.write(r.read)
end
end
- elsif File.exist?(url)
- FileUtils.cp(url, path)
else
Chef::Application.fatal! "You specified --recipe-url but the value is neither a valid URL nor a path to a file that exists on disk." +
"Please confirm the location of the tarball and try again."