Move to upstream progress bar, deleting our fork - needed patches merged by upstream maintainer

This commit is contained in:
Harshavardhana
2015-06-11 14:47:18 -07:00
parent 921153341b
commit eb5d6ab84f
16 changed files with 37 additions and 24 deletions
+5 -5
View File
@@ -1,10 +1,14 @@
{
"ImportPath": "github.com/minio/mc",
"GoVersion": "go1.4.2",
"GoVersion": "go1.4",
"Packages": [
"./..."
],
"Deps": [
{
"ImportPath": "github.com/cheggaaa/pb",
"Rev": "e648e12b78cedf14ebb2fc1855033f07b034cfbb"
},
{
"ImportPath": "github.com/dustin/go-humanize",
"Rev": "8cc1aaa2d955ee82833337cfb10babc42be6bce6"
@@ -34,10 +38,6 @@
"ImportPath": "github.com/minio/minio/pkg/iodine",
"Rev": "0f58045480309d4b13fe45878f05736c3ff20e7e"
},
{
"ImportPath": "github.com/minio/pb",
"Rev": "23b3da381ac6aed453db51c316a90564f4f3ba7e"
},
{
"ImportPath": "github.com/shiena/ansicolor",
"Rev": "8368d3b31cf6f2c2464c7a91675342c9a0ac6658"
@@ -97,7 +97,6 @@ func (pb *ProgressBar) Start() *ProgressBar {
pb.startTime = time.Now()
pb.startValue = pb.current
if pb.Total == 0 {
pb.ShowBar = false
pb.ShowTimeLeft = false
pb.ShowPercent = false
}
@@ -239,7 +238,7 @@ func (pb *ProgressBar) write(current int64) {
if pb.Total > 0 {
countersBox = fmt.Sprintf("%s / %s ", Format(current, pb.Units), Format(pb.Total, pb.Units))
} else {
countersBox = Format(current, pb.Units) + " "
countersBox = Format(current, pb.Units) + " / ? "
}
}
@@ -272,22 +271,36 @@ func (pb *ProgressBar) write(current int64) {
if pb.ShowBar {
size := width - len(countersBox+pb.BarStart+pb.BarEnd+percentBox+timeLeftBox+speedBox+pb.prefix+pb.postfix)
if size > 0 {
curCount := int(math.Ceil((float64(current) / float64(pb.Total)) * float64(size)))
emptCount := size - curCount
barBox = pb.BarStart
if emptCount < 0 {
emptCount = 0
}
if curCount > size {
curCount = size
}
if emptCount <= 0 {
barBox += strings.Repeat(pb.Current, curCount)
} else if curCount > 0 {
barBox += strings.Repeat(pb.Current, curCount-1) + pb.CurrentN
}
if pb.Total > 0 {
curCount := int(math.Ceil((float64(current) / float64(pb.Total)) * float64(size)))
emptCount := size - curCount
barBox = pb.BarStart
if emptCount < 0 {
emptCount = 0
}
if curCount > size {
curCount = size
}
if emptCount <= 0 {
barBox += strings.Repeat(pb.Current, curCount)
} else if curCount > 0 {
barBox += strings.Repeat(pb.Current, curCount-1) + pb.CurrentN
}
barBox += strings.Repeat(pb.Empty, emptCount) + pb.BarEnd
barBox += strings.Repeat(pb.Empty, emptCount) + pb.BarEnd
} else {
barBox = pb.BarStart
pos := size - int(current)%int(size)
if pos-1 > 0 {
barBox += strings.Repeat(pb.Empty, pos-1)
}
barBox += pb.Current
if size-pos-1 > 0 {
barBox += strings.Repeat(pb.Empty, size-pos-1)
}
barBox += pb.BarEnd
}
}
}
+1 -1
View File
@@ -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
+1 -1
View File
@@ -24,10 +24,10 @@ import (
"runtime"
"strconv"
"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.