From 918b5c06a06909de6095eb6e0be0e15fe3f86d1d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 9 Oct 2015 15:35:18 -0700 Subject: [PATCH] Use FormatBytes from pb project for a consistent view --- accounting-reader.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/accounting-reader.go b/accounting-reader.go index b1714c5a..bec3a665 100644 --- a/accounting-reader.go +++ b/accounting-reader.go @@ -23,7 +23,7 @@ import ( "sync/atomic" "time" - "github.com/dustin/go-humanize" + "github.com/minio/pb" ) type accountingReader struct { @@ -64,7 +64,10 @@ func (a *accounter) write(current int64) string { if currentFromStart > 0 { speed := float64(currentFromStart) / (float64(fromStart) / float64(time.Second)) - speedBox = humanize.IBytes(uint64(speed)) + speedBox = pb.FormatBytes(int64(speed)) + } + if speedBox == "" { + speedBox = "0 MB" } return speedBox + "/s" } @@ -85,8 +88,8 @@ func (a *accounter) Finish() string { var message string a.finishOnce.Do(func() { close(a.isFinished) - message = fmt.Sprintf("Total: %s, Transferred: %s, Speed: %s", humanize.IBytes(uint64(a.Total)), - humanize.IBytes(uint64(a.current)), a.write(atomic.LoadInt64(&a.current))) + message = fmt.Sprintf("Total: %s, Transferred: %s, Speed: %s", pb.FormatBytes(a.Total), + pb.FormatBytes(a.current), a.write(atomic.LoadInt64(&a.current))) }) return message }