Codebase list golang-github-vbauerster-mpb / 280637f
SetTotal to current if total <= 0 Vladimir Bauer 6 years ago
2 changed file(s) with 7 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
211211 func (b *Bar) SetTotal(total int64, complete bool) {
212212 select {
213213 case b.operateState <- func(s *bState) {
214 s.total = total
214 if total <= 0 {
215 s.total = s.current
216 } else {
217 s.total = total
218 }
215219 if complete && !s.toComplete {
216220 s.current = s.total
217221 s.toComplete = true
1818 }
1919 if err == io.EOF {
2020 go func() {
21 prox.bar.SetTotal(prox.bar.Current(), true)
21 prox.bar.SetTotal(0, true)
2222 }()
2323 }
2424 return
3737 }
3838 if err == io.EOF {
3939 go func() {
40 prox.bar.SetTotal(prox.bar.Current(), true)
40 prox.bar.SetTotal(0, true)
4141 }()
4242 }
4343 return