fix: avoid Update deadlock by unlocking before display

This commit is contained in:
2026-01-19 16:37:15 +01:00
parent 7be196e4c3
commit 628db14f59

View File

@@ -56,16 +56,16 @@ func newProgressIndicatorWithClock(total int, description string, c clock) *Prog
func (p *ProgressIndicator) Update(current int) { func (p *ProgressIndicator) Update(current int) {
p.mu.Lock() p.mu.Lock()
defer p.mu.Unlock()
p.current = current p.current = current
now := p.clock.Now() now := p.clock.Now()
if now.Sub(p.lastUpdate) < 100*time.Millisecond { if now.Sub(p.lastUpdate) < 100*time.Millisecond {
p.mu.Unlock()
return return
} }
p.lastUpdate = now p.lastUpdate = now
p.mu.Unlock()
p.display() p.display()
} }