diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 464b31bb..52db39ff 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,14 +1,10 @@ { "ImportPath": "github.com/minio/mc", - "GoVersion": "go1.4", + "GoVersion": "go1.4.2", "Packages": [ "./..." ], "Deps": [ - { - "ImportPath": "github.com/cheggaaa/pb", - "Rev": "bd14546a551971ae7f460e6d6e527c5b56cd38d7" - }, { "ImportPath": "github.com/dustin/go-humanize", "Rev": "8cc1aaa2d955ee82833337cfb10babc42be6bce6" @@ -38,6 +34,10 @@ "ImportPath": "github.com/minio/minio/pkg/iodine", "Rev": "0f58045480309d4b13fe45878f05736c3ff20e7e" }, + { + "ImportPath": "github.com/minio/pb", + "Rev": "23b3da381ac6aed453db51c316a90564f4f3ba7e" + }, { "ImportPath": "github.com/shiena/ansicolor", "Rev": "8368d3b31cf6f2c2464c7a91675342c9a0ac6658" diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/LICENSE b/Godeps/_workspace/src/github.com/minio/pb/LICENSE similarity index 100% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/LICENSE rename to Godeps/_workspace/src/github.com/minio/pb/LICENSE diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/README.md b/Godeps/_workspace/src/github.com/minio/pb/README.md similarity index 100% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/README.md rename to Godeps/_workspace/src/github.com/minio/pb/README.md diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/example/copy/copy.go b/Godeps/_workspace/src/github.com/minio/pb/example/copy/copy.go similarity index 100% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/example/copy/copy.go rename to Godeps/_workspace/src/github.com/minio/pb/example/copy/copy.go diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/example/pb.go b/Godeps/_workspace/src/github.com/minio/pb/example/pb.go similarity index 100% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/example/pb.go rename to Godeps/_workspace/src/github.com/minio/pb/example/pb.go diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/format.go b/Godeps/_workspace/src/github.com/minio/pb/format.go similarity index 100% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/format.go rename to Godeps/_workspace/src/github.com/minio/pb/format.go diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/format_test.go b/Godeps/_workspace/src/github.com/minio/pb/format_test.go similarity index 100% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/format_test.go rename to Godeps/_workspace/src/github.com/minio/pb/format_test.go diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/pb.go b/Godeps/_workspace/src/github.com/minio/pb/pb.go similarity index 92% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/pb.go rename to Godeps/_workspace/src/github.com/minio/pb/pb.go index ac3eec4c..fb8112e0 100644 --- a/Godeps/_workspace/src/github.com/cheggaaa/pb/pb.go +++ b/Godeps/_workspace/src/github.com/minio/pb/pb.go @@ -80,6 +80,7 @@ type ProgressBar struct { isFinish chan struct{} startTime time.Time + startValue int64 currentValue int64 prefix, postfix string @@ -94,6 +95,7 @@ type ProgressBar struct { // Start print func (pb *ProgressBar) Start() *ProgressBar { pb.startTime = time.Now() + pb.startValue = pb.current if pb.Total == 0 { pb.ShowBar = false pb.ShowTimeLeft = false @@ -111,13 +113,14 @@ func (pb *ProgressBar) Increment() int { } // Set current value -func (pb *ProgressBar) Set(current int) { - pb.Set64(int64(current)) +func (pb *ProgressBar) Set(current int) *ProgressBar { + return pb.Set64(int64(current)) } // Set64 sets the current value as int64 -func (pb *ProgressBar) Set64(current int64) { +func (pb *ProgressBar) Set64(current int64) *ProgressBar { atomic.StoreInt64(&pb.current, current) + return pb } // Add to current value @@ -221,7 +224,7 @@ func (pb *ProgressBar) NewProxyReader(r io.Reader) *Reader { } func (pb *ProgressBar) write(current int64) { - width := pb.getWidth() + width := pb.GetWidth() var percentBox, countersBox, timeLeftBox, speedBox, barBox, end, out string @@ -242,6 +245,7 @@ func (pb *ProgressBar) write(current int64) { // time left fromStart := time.Now().Sub(pb.startTime) + currentFromStart := current - pb.startValue select { case <-pb.isFinish: if pb.ShowFinalTime { @@ -249,18 +253,18 @@ func (pb *ProgressBar) write(current int64) { timeLeftBox = left.String() } default: - if pb.ShowTimeLeft && current > 0 { - perEntry := fromStart / time.Duration(current) - left := time.Duration(pb.Total-current) * perEntry + if pb.ShowTimeLeft && currentFromStart > 0 { + perEntry := fromStart / time.Duration(currentFromStart) + left := time.Duration(pb.Total-currentFromStart) * perEntry left = (left / time.Second) * time.Second timeLeftBox = left.String() } } // speed - if pb.ShowSpeed && current > 0 { + if pb.ShowSpeed && currentFromStart > 0 { fromStart := time.Now().Sub(pb.startTime) - speed := float64(current) / (float64(fromStart) / float64(time.Second)) + speed := float64(currentFromStart) / (float64(fromStart) / float64(time.Second)) speedBox = Format(int64(speed), pb.Units) + "/s " } @@ -304,7 +308,7 @@ func (pb *ProgressBar) write(current int64) { } } -func (pb *ProgressBar) getWidth() int { +func (pb *ProgressBar) GetWidth() int { if pb.ForceWidth { return pb.Width } diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_nix.go b/Godeps/_workspace/src/github.com/minio/pb/pb_nix.go similarity index 100% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/pb_nix.go rename to Godeps/_workspace/src/github.com/minio/pb/pb_nix.go diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_solaris.go b/Godeps/_workspace/src/github.com/minio/pb/pb_solaris.go similarity index 100% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/pb_solaris.go rename to Godeps/_workspace/src/github.com/minio/pb/pb_solaris.go diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_test.go b/Godeps/_workspace/src/github.com/minio/pb/pb_test.go similarity index 100% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/pb_test.go rename to Godeps/_workspace/src/github.com/minio/pb/pb_test.go diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_win.go b/Godeps/_workspace/src/github.com/minio/pb/pb_win.go similarity index 100% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/pb_win.go rename to Godeps/_workspace/src/github.com/minio/pb/pb_win.go diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_x.go b/Godeps/_workspace/src/github.com/minio/pb/pb_x.go similarity index 100% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/pb_x.go rename to Godeps/_workspace/src/github.com/minio/pb/pb_x.go diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/reader.go b/Godeps/_workspace/src/github.com/minio/pb/reader.go similarity index 100% rename from Godeps/_workspace/src/github.com/cheggaaa/pb/reader.go rename to Godeps/_workspace/src/github.com/minio/pb/reader.go diff --git a/cp-bar.go b/cp-bar.go index dbbb06ae..b0b09702 100644 --- a/cp-bar.go +++ b/cp-bar.go @@ -23,8 +23,8 @@ import ( "sync/atomic" "time" - "github.com/cheggaaa/pb" "github.com/minio/mc/pkg/console" + "github.com/minio/pb" ) type cpBarCmd int @@ -120,6 +120,10 @@ func newCpBar() barSend { switch msg.Cmd { case cpBarCmdSetPrefix: barCaption = msg.Arg.(string) + if bar.GetWidth() < len(barCaption) { + trimSize := len(barCaption) - bar.GetWidth() + 3 + 1 + barCaption = "..." + barCaption[trimSize:] + } case cpBarCmdExtend: atomic.AddInt64(&bar.Total, msg.Arg.(int64)) case cpBarCmdProgress: diff --git a/main.go b/main.go index 47be0ccf..d57ab04a 100644 --- a/main.go +++ b/main.go @@ -25,10 +25,10 @@ import ( "strconv" "time" - "github.com/cheggaaa/pb" "github.com/minio/cli" "github.com/minio/mc/pkg/console" "github.com/minio/minio/pkg/iodine" + "github.com/minio/pb" ) // Check for the environment early on and gracefully report.