diff options
author | tyler-ball <tball@chef.io> | 2018-08-03 13:10:25 -0600 |
---|---|---|
committer | tyler-ball <tball@chef.io> | 2018-08-07 14:44:16 -0600 |
commit | 4ba68cbe05f201d1e2dcabfedbb1cc17bc032c3f (patch) | |
tree | 123545cefd73f2a4ffdea5560b95d5a6c8994bc0 | |
parent | 6d79935c4a69f8ba1ba52844b65201773e38fba6 (diff) | |
download | chef-4ba68cbe05f201d1e2dcabfedbb1cc17bc032c3f.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>
-rw-r--r-- | lib/chef/application/client.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb index 7713350352..c94af6f0d2 100644 --- a/lib/chef/application/client.rb +++ b/lib/chef/application/client.rb @@ -529,14 +529,14 @@ class Chef::Application::Client < Chef::Application def fetch_recipe_tarball(url, path) Chef::Log.debug("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." |