Drop progress while total is dynamic
Vladimir Bauer
8 years ago
| 149 | 149 | s.updateTimePerItemEstimate(n, now, next) |
| 150 | 150 | s.timeElapsed = now.Sub(s.startTime) |
| 151 | 151 | } |
| 152 | sum := s.current + int64(n) | |
| 153 | if s.total > 0 && sum >= s.total { | |
| 154 | if s.dynamic { | |
| 155 | sum -= sum * s.dropRatio / 100 | |
| 156 | } else { | |
| 157 | s.current = s.total | |
| 158 | s.completed = true | |
| 152 | s.current += int64(n) | |
| 153 | if s.dynamic { | |
| 154 | for s.current >= s.total { | |
| 155 | s.current -= s.current * s.dropRatio / 100 | |
| 159 | 156 | } |
| 160 | return | |
| 161 | } | |
| 162 | s.current = sum | |
| 157 | } else if s.current >= s.total { | |
| 158 | s.current = s.total | |
| 159 | s.completed = true | |
| 160 | } | |
| 163 | 161 | }: |
| 164 | 162 | case <-b.quit: |
| 165 | 163 | } |