Progress: Don't panic for not running progress

This commit is contained in:
Alexander Neumann 2015-03-22 14:12:51 +01:00
parent 2506fa9bef
commit f2df072f48

View file

@ -42,14 +42,10 @@ func NewProgress(d time.Duration) *Progress {
// Start runs resets and runs the progress reporter.
func (p *Progress) Start() {
if p == nil {
if p == nil || p.running {
return
}
if p.running {
panic("truing to reset a running Progress")
}
p.o = sync.Once{}
p.cancel = make(chan struct{})
p.running = true
@ -135,14 +131,10 @@ func (p *Progress) Reset() {
// Done closes the progress report.
func (p *Progress) Done() {
if p == nil {
if p == nil || !p.running {
return
}
if !p.running {
panic("Done() called on non-running Progress")
}
if p.running {
p.running = false
p.o.Do(func() {