Permalink
Browse files

Don't attempt to calculate percentage if total is not set

Prevents a FloatDomainError if the total is zero or not known. Fixes #788.
  • Loading branch information...
1 parent f8fa859 commit 38212969c6ac22ccde6676f6e160957f2fd793a1 @dansimau dansimau committed Mar 9, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/vagrant/ui.rb
View
@@ -78,9 +78,13 @@ def ask(message, opts=nil)
# to the UI. Send `clear_line` to clear the line to show
# a continuous progress meter.
def report_progress(progress, total, show_parts=true)
- percent = (progress.to_f / total.to_f) * 100
- line = "Progress: #{percent.to_i}%"
- line << " (#{progress} / #{total})" if show_parts
+ if total and not total == 0
+ percent = (progress.to_f / total.to_f) * 100
+ line = "Progress: #{percent.to_i}%"
+ line << " (#{progress} / #{total})" if show_parts
+ else
+ line = "Progress: #{progress}"
+ end
info(line, :new_line => false)
end

0 comments on commit 3821296

Please sign in to comment.