diff --git a/progress.go b/progress.go index c36e803..af1ce66 100644 --- a/progress.go +++ b/progress.go @@ -62,12 +62,12 @@ // WaitGroup for internal rendering sync wg *sync.WaitGroup - done chan struct{} - userConfCh chan userConf - bCommandCh chan *bCommandData - barCountCh chan int - stopReqCh chan struct{} - totalUnknownBarStopReqCh chan struct{} + done chan struct{} + userConfCh chan userConf + bCommandCh chan *bCommandData + barCountCh chan int + stopReqCh chan struct{} + uncompletedBarStopReqCh chan struct{} // follawing is used after (*Progress.done) is closed conf userConf @@ -78,13 +78,13 @@ // If you don't plan to cancel, it is safe to feed with nil func New() *Progress { p := &Progress{ - wg: new(sync.WaitGroup), - done: make(chan struct{}), - userConfCh: make(chan userConf), - bCommandCh: make(chan *bCommandData), - barCountCh: make(chan int), - stopReqCh: make(chan struct{}), - totalUnknownBarStopReqCh: make(chan struct{}), + wg: new(sync.WaitGroup), + done: make(chan struct{}), + userConfCh: make(chan userConf), + bCommandCh: make(chan *bCommandData), + barCountCh: make(chan int), + stopReqCh: make(chan struct{}), + uncompletedBarStopReqCh: make(chan struct{}), } go p.server(userConf{ width: pwidth, @@ -214,7 +214,7 @@ return default: // complet Total unknown bars - p.totalUnknownBarStopReqCh <- struct{}{} + p.uncompletedBarStopReqCh <- struct{}{} // wait for all bars to quit p.wg.Wait() // stop request @@ -333,9 +333,10 @@ for _, b := range bars { b.flushed() } - case <-p.totalUnknownBarStopReqCh: + case <-p.uncompletedBarStopReqCh: for _, b := range bars { - if b.GetStatistics().Total <= 0 { + stat := b.GetStatistics() + if !stat.Completed { b.Completed() } }