diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 64a67a93..9ae80006 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -5,6 +5,10 @@ "./..." ], "Deps": [ + { + "ImportPath": "github.com/cheggaaa/pb", + "Rev": "bd14546a551971ae7f460e6d6e527c5b56cd38d7" + }, { "ImportPath": "github.com/dustin/go-humanize", "Rev": "8cc1aaa2d955ee82833337cfb10babc42be6bce6" @@ -34,10 +38,6 @@ "ImportPath": "github.com/minio/objectstorage-go", "Rev": "191883582ed0260d7be8f091971d5a7a840621d0" }, - { - "ImportPath": "github.com/minio/pb", - "Rev": "622417a09783776be7c59be7c01feebd0b5423bf" - }, { "ImportPath": "github.com/shiena/ansicolor", "Rev": "8368d3b31cf6f2c2464c7a91675342c9a0ac6658" diff --git a/Godeps/_workspace/src/github.com/minio/pb/LICENSE b/Godeps/_workspace/src/github.com/cheggaaa/pb/LICENSE similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/LICENSE rename to Godeps/_workspace/src/github.com/cheggaaa/pb/LICENSE diff --git a/Godeps/_workspace/src/github.com/minio/pb/README.md b/Godeps/_workspace/src/github.com/cheggaaa/pb/README.md similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/README.md rename to Godeps/_workspace/src/github.com/cheggaaa/pb/README.md diff --git a/Godeps/_workspace/src/github.com/minio/pb/example/copy/copy.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/example/copy/copy.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/example/copy/copy.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/example/copy/copy.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/example/pb.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/example/pb.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/example/pb.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/example/pb.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/format.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/format.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/format.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/format.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/format_test.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/format_test.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/format_test.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/format_test.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/pb.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb.go similarity index 91% rename from Godeps/_workspace/src/github.com/minio/pb/pb.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/pb.go index d61c7423..ac3eec4c 100644 --- a/Godeps/_workspace/src/github.com/minio/pb/pb.go +++ b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb.go @@ -80,7 +80,6 @@ type ProgressBar struct { isFinish chan struct{} startTime time.Time - startValue int64 currentValue int64 prefix, postfix string @@ -95,7 +94,6 @@ 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 @@ -113,14 +111,13 @@ func (pb *ProgressBar) Increment() int { } // Set current value -func (pb *ProgressBar) Set(current int) *ProgressBar { - return pb.Set64(int64(current)) +func (pb *ProgressBar) Set(current int) { + pb.Set64(int64(current)) } // Set64 sets the current value as int64 -func (pb *ProgressBar) Set64(current int64) *ProgressBar { +func (pb *ProgressBar) Set64(current int64) { atomic.StoreInt64(&pb.current, current) - return pb } // Add to current value @@ -191,10 +188,7 @@ func (pb *ProgressBar) Finish() { //Protect multiple calls pb.finishOnce.Do(func() { close(pb.isFinish) - // if current is 0 do not worry about writing to progress bar - if pb.current > 0 { - pb.write(atomic.LoadInt64(&pb.current)) - } + pb.write(atomic.LoadInt64(&pb.current)) if !pb.NotPrint { fmt.Println() } @@ -248,7 +242,6 @@ 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 { @@ -256,18 +249,18 @@ func (pb *ProgressBar) write(current int64) { timeLeftBox = left.String() } default: - if pb.ShowTimeLeft && currentFromStart > 0 { - perEntry := fromStart / time.Duration(currentFromStart) - left := time.Duration(pb.Total-currentFromStart) * perEntry + if pb.ShowTimeLeft && current > 0 { + perEntry := fromStart / time.Duration(current) + left := time.Duration(pb.Total-current) * perEntry left = (left / time.Second) * time.Second timeLeftBox = left.String() } } // speed - if pb.ShowSpeed && currentFromStart > 0 { + if pb.ShowSpeed && current > 0 { fromStart := time.Now().Sub(pb.startTime) - speed := float64(currentFromStart) / (float64(fromStart) / float64(time.Second)) + speed := float64(current) / (float64(fromStart) / float64(time.Second)) speedBox = Format(int64(speed), pb.Units) + "/s " } diff --git a/Godeps/_workspace/src/github.com/minio/pb/pb_nix.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_nix.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/pb_nix.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/pb_nix.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/pb_solaris.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_solaris.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/pb_solaris.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/pb_solaris.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/pb_test.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_test.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/pb_test.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/pb_test.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/pb_win.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_win.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/pb_win.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/pb_win.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/pb_x.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_x.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/pb_x.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/pb_x.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/reader.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/reader.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/reader.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/reader.go diff --git a/cmd-copy.go b/cmd-copy.go index 15ba1bf6..ec8e8616 100644 --- a/cmd-copy.go +++ b/cmd-copy.go @@ -103,7 +103,8 @@ func runCopyCmd(ctx *cli.Context) { go func(sourceURLs []string, targetURL string) { for cpURLs := range prepareCopyURLs(sourceURLs, targetURL) { if cpURLs.Error != nil { - console.Errorln(iodine.ToError(cpURLs.Error)) + // no need to print errors here, any error here + // will be printed later during Copy() continue } bar.Extend(cpURLs.SourceContent.Size) @@ -116,10 +117,9 @@ func runCopyCmd(ctx *cli.Context) { for cpURLs := range prepareCopyURLs(sourceURLs, targetURL) { if cpURLs.Error != nil { - console.Errorf(iodine.ToError(cpURLs.Error).Error()) + console.Errorln(iodine.ToError(cpURLs.Error).Error()) continue } - cpQueue <- true wg.Add(1) go func(cpURLs copyURLs) { @@ -134,9 +134,7 @@ func runCopyCmd(ctx *cli.Context) { console.Errorln(err) return } - if tgtConfig != nil && srcConfig != nil { - doCopy(cpURLs.SourceContent.Name, srcConfig, cpURLs.TargetContent.Name, tgtConfig, &bar) - } + doCopy(cpURLs.SourceContent.Name, srcConfig, cpURLs.TargetContent.Name, tgtConfig, &bar) <-cpQueue }(*cpURLs) } diff --git a/copy-bar.go b/copy-bar.go index aae1698a..4e7245c4 100644 --- a/copy-bar.go +++ b/copy-bar.go @@ -20,8 +20,8 @@ import ( "io" "time" + "github.com/cheggaaa/pb" "github.com/minio/mc/pkg/console" - "github.com/minio/pb" ) type copyBarCmd int @@ -94,7 +94,9 @@ func newCopyBar(quiet bool) barSend { case copyBarCmdProgress: bar.Add64(msg.Arg.(int64)) case copyBarCmdFinish: - bar.Finish() + if started { + bar.Finish() + } finishCh <- true return } diff --git a/main.go b/main.go index 4e5263d7..ee9ec543 100644 --- a/main.go +++ b/main.go @@ -24,10 +24,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.