diff options
author | Thom May <thom@chef.io> | 2016-03-03 10:11:29 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-03-03 10:11:29 +0000 |
commit | 788ec4597c9f1517c26d85703bdc79ea01e5ff53 (patch) | |
tree | 23364a04f0906df0697565ba84f9163b48a61298 /lib/chef/provider/remote_file | |
parent | a4d98365c1d68d7a24fba62783538951d2bbd2e0 (diff) | |
parent | 9c7bc8730af9ddba70d5095301517ae9e07e5024 (diff) | |
download | chef-788ec4597c9f1517c26d85703bdc79ea01e5ff53.tar.gz |
Merge branch 'remote-file-download-progress' of https://github.com/brandocorp/chef into tm/remote_file_download_progress
Diffstat (limited to 'lib/chef/provider/remote_file')
-rw-r--r-- | lib/chef/provider/remote_file/http.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/chef/provider/remote_file/http.rb b/lib/chef/provider/remote_file/http.rb index 6fa574e777..3b97d116aa 100644 --- a/lib/chef/provider/remote_file/http.rb +++ b/lib/chef/provider/remote_file/http.rb @@ -39,6 +39,10 @@ class Chef @current_resource = current_resource end + def events + new_resource.events + end + def headers conditional_get_headers.merge(new_resource.headers) end @@ -57,7 +61,13 @@ class Chef def fetch http = Chef::HTTP::Simple.new(uri, http_client_opts) - tempfile = http.streaming_request(uri, headers) + if want_progress? + tempfile = http.streaming_request_with_progress(uri, headers) do |size, total| + events.resource_action_progress(new_resource, size, total, new_resource.progress_interval) + end + else + tempfile = http.streaming_request(uri, headers) + end if tempfile update_cache_control_data(tempfile, http.last_response) tempfile.close @@ -78,6 +88,10 @@ class Chef @cache_control_data ||= CacheControlData.load_and_validate(uri, current_resource.checksum) end + def want_progress? + new_resource.show_progress + end + def want_mtime_cache_control? new_resource.use_last_modified end |