diff options
author | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-09-19 17:01:10 +0530 |
---|---|---|
committer | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-09-19 17:01:10 +0530 |
commit | aaae16232cb1e17ac9b8060c3237f0bc6691e845 (patch) | |
tree | 035f13b9538f502ebe41209b1020cb2deaa08a82 /lib/chef/formatters | |
parent | 4e5908e297f26f19ad5da2cefaa46579db38d266 (diff) | |
download | chef-aaae16232cb1e17ac9b8060c3237f0bc6691e845.tar.gz |
Fix show_progress in remote_file is causing FloatDomainError: Infinity
- Add check to avoid total if zero or nil.
- Set @progress[resource] default value to -1 so that it can start with 0%.
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
Diffstat (limited to 'lib/chef/formatters')
-rw-r--r-- | lib/chef/formatters/doc.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb index 5ed75c00eb..0a4edd2f8b 100644 --- a/lib/chef/formatters/doc.rb +++ b/lib/chef/formatters/doc.rb @@ -236,11 +236,11 @@ class Chef end def resource_update_progress(resource, current, total, interval) - @progress[resource] ||= 0 + @progress[resource] ||= -1 - percent_complete = (current.to_f / total.to_f * 100).to_i + percent_complete = (current.to_f / total.to_f * 100).to_i unless total.to_f == 0.0 - if percent_complete > @progress[resource] + if percent_complete && percent_complete > @progress[resource] @progress[resource] = percent_complete |