SetTotal to current if total <= 0
Vladimir Bauer
6 years ago
| 211 | 211 |
func (b *Bar) SetTotal(total int64, complete bool) {
|
| 212 | 212 |
select {
|
| 213 | 213 |
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 |
}
|
| 215 | 219 |
if complete && !s.toComplete {
|
| 216 | 220 |
s.current = s.total
|
| 217 | 221 |
s.toComplete = true
|
| 18 | 18 |
}
|
| 19 | 19 |
if err == io.EOF {
|
| 20 | 20 |
go func() {
|
| 21 | |
prox.bar.SetTotal(prox.bar.Current(), true)
|
|
21 |
prox.bar.SetTotal(0, true)
|
| 22 | 22 |
}()
|
| 23 | 23 |
}
|
| 24 | 24 |
return
|
|
| 37 | 37 |
}
|
| 38 | 38 |
if err == io.EOF {
|
| 39 | 39 |
go func() {
|
| 40 | |
prox.bar.SetTotal(prox.bar.Current(), true)
|
|
40 |
prox.bar.SetTotal(0, true)
|
| 41 | 41 |
}()
|
| 42 | 42 |
}
|
| 43 | 43 |
return
|