Browse code

fix divide by zero error

Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)

Victor Vieux authored on 2014/02/25 17:01:46
Showing 1 changed files
... ...
@@ -52,7 +52,7 @@ func (p *JSONProgress) String() string {
52 52
 	}
53 53
 	numbersBox = fmt.Sprintf("%8v/%v", current, total)
54 54
 
55
-	if p.Start > 0 && percentage < 50 {
55
+	if p.Current > 0 && p.Start > 0 && percentage < 50 {
56 56
 		fromStart := time.Now().UTC().Sub(time.Unix(int64(p.Start), 0))
57 57
 		perEntry := fromStart / time.Duration(p.Current)
58 58
 		left := time.Duration(p.Total-p.Current) * perEntry