forked from TrueCloudLab/restic
Progress: Don't panic for not running progress
This commit is contained in:
parent
2506fa9bef
commit
f2df072f48
1 changed files with 2 additions and 10 deletions
12
progress.go
12
progress.go
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue