fix some race conditions

This commit is contained in:
Adrien Delorme 2018-10-15 13:53:59 +02:00
parent cf2c309c5e
commit 56ccba86c7
1 changed files with 6 additions and 3 deletions

View File

@ -66,7 +66,9 @@ func (spb *StackableProgressBar) Start(total int64) {
func (spb *StackableProgressBar) Add(total int64) {
spb.mtx.Lock()
defer spb.mtx.Unlock()
if spb.Bar.ProgressBar != nil {
spb.Bar.Add(total)
}
}
func (spb *StackableProgressBar) NewProxyReader(r io.Reader) io.Reader {
@ -87,12 +89,13 @@ func (spb *StackableProgressBar) Finish() {
if spb.items == 0 {
// slef cleanup
spb.Bar.ProgressBar.Finish()
spb.Bar.ProgressBar = nil
spb.started = false
spb.total = 0
return
}
if spb.Bar.ProgressBar != nil {
spb.prefix()
}
}
// BasicProgressBar is packer's basic progress bar.