From 38212969c6ac22ccde6676f6e160957f2fd793a1 Mon Sep 17 00:00:00 2001 From: Daniel Simmons Date: Fri, 9 Mar 2012 11:10:30 +0000 Subject: [PATCH] Don't attempt to calculate percentage if total is not set Prevents a FloatDomainError if the total is zero or not known. Fixes #788. --- lib/vagrant/ui.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index bcbf16146..3fd6e3a01 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -78,9 +78,13 @@ module Vagrant # 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