Codebase list golang-github-vbauerster-mpb / 4612884
Total from int to int64 Vladimir Bauer 9 years ago
5 changed file(s) with 16 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
4141 // Refil is a struct for b.IncrWithReFill
4242 type refill struct {
4343 char rune
44 till int
44 till int64
4545 }
4646
4747 type (
5454 width int
5555 format barFmtRunes
5656 etaAlpha float64
57 total int
58 current int
57 total int64
58 current int64
5959 trimLeftSpace bool
6060 trimRightSpace bool
6161 completed bool
7171 }
7272 )
7373
74 func newBar(total int, wg *sync.WaitGroup, cancel <-chan struct{}, options ...BarOption) *Bar {
74 func newBar(total int64, wg *sync.WaitGroup, cancel <-chan struct{}, options ...BarOption) *Bar {
7575 s := state{
7676 total: total,
7777 etaAlpha: etaAlpha,
136136 s.startTime = time.Now()
137137 s.blockStartTime = s.startTime
138138 }
139 sum := s.current + n
139 sum := s.current + int64(n)
140140 s.timeElapsed = time.Since(s.startTime)
141141 s.updateTimePerItemEstimate(n)
142142 if s.total > 0 && sum >= s.total {
154154
155155 // ResumeFill fills bar with different r rune,
156156 // from 0 to till amount of progress.
157 func (b *Bar) ResumeFill(r rune, till int) {
157 func (b *Bar) ResumeFill(r rune, till int64) {
158158 if till < 1 {
159159 return
160160 }
369369 return buf
370370 }
371371
372 func fillBar(total, current, width int, fmtBytes barFmtBytes, rf *refill) []byte {
372 func fillBar(total, current int64, width int, fmtBytes barFmtBytes, rf *refill) []byte {
373373 if width < 2 || total <= 0 {
374374 return []byte{}
375375 }
2929 ID int
3030 Completed bool
3131 Aborted bool
32 Total int
33 Current int
32 Total int64
33 Current int64
3434 StartTime time.Time
3535 TimeElapsed time.Duration
3636 TimePerItemEstimate time.Duration
145145 }
146146 }
147147
148 func CalcPercentage(total, current, width int) int {
148 func CalcPercentage(total, current int64, width int) int {
149149 if total == 0 || current > total {
150150 return 0
151151 }
2626
2727 type Units uint
2828
29 func Format(i int) *formatter {
29 func Format(i int64) *formatter {
3030 return &formatter{n: i}
3131 }
3232
3333 type formatter struct {
34 n int
34 n int64
3535 unit Units
3636 width int
3737 }
5757 }
5858 }
5959
60 func formatKiB(i int) (result string) {
60 func formatKiB(i int64) (result string) {
6161 switch {
6262 case i >= TiB:
6363 result = fmt.Sprintf("%.1fTiB", float64(i)/TiB)
7373 return
7474 }
7575
76 func formatKB(i int) (result string) {
76 func formatKB(i int64) (result string) {
7777 switch {
7878 case i >= TB:
7979 result = fmt.Sprintf("%.1fTB", float64(i)/TB)
2727 if i != 1 {
2828 name = fmt.Sprintf("Bar#%d:", i)
2929 }
30 b := p.AddBar(total,
30 b := p.AddBar(int64(total),
3131 mpb.PrependDecorators(
3232 decor.Name(name, 0, decor.DwidthSync|decor.DidentRight),
3333 decor.ETA(4, decor.DSyncSpace),
8282 }
8383
8484 // AddBar creates a new progress bar and adds to the container.
85 func (p *Progress) AddBar(total int, options ...BarOption) *Bar {
85 func (p *Progress) AddBar(total int64, options ...BarOption) *Bar {
8686 result := make(chan *Bar, 1)
8787 op := func(c *pConf) {
8888 options = append(options, barWidth(c.width), barFormat(c.format))