summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-11-01 17:20:07 +0000
committerGitHub <noreply@github.com>2016-11-01 17:20:07 +0000
commitc3629bd51033f45c5c6fb227b24ab90ca7bcfd56 (patch)
tree7e0e75f32f4570f9f4a3f3cc702c740ba7dd2a0b
parentbed596d1010fdb8428577b43d1fbc26cfbe6f01b (diff)
parent13a02abe2d02a59c846fb0a65d8429314652d618 (diff)
downloadchef-c3629bd51033f45c5c6fb227b24ab90ca7bcfd56.tar.gz
Merge pull request #5494 from MsysTechnologiesllc/ali/knife_download_cookbooks_fix
Fixed knife download cookbooks issue which used to corrupt the certificate files each time the command was fired.
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb
index 426cc62039..ad50054dc9 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb
@@ -39,17 +39,13 @@ class Chef
def read
begin
tmpfile = rest.streaming_request(file[:url])
+ File.open(tmpfile, "rb") { |f| f.read }
rescue Timeout::Error => e
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "Timeout reading #{file[:url]}: #{e}")
rescue Net::HTTPServerException => e
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "#{e.message} retrieving #{file[:url]}")
- end
-
- begin
- tmpfile.open
- tmpfile.read
- ensure
- tmpfile.close!
+ rescue Errno::ENOENT
+ raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
end
end