mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-17 10:35:11 +00:00
Move the ticker closer to where it's used and defer stop it to avoid
missing a branch.
Fixes regression introduced in
2f3eacdb6c
Fixes https://github.com/syncthing/syncthing/issues/9417
This commit is contained in:
parent
eb9cd363d0
commit
2ab2488274
@ -142,8 +142,6 @@ func (w *walker) walk(ctx context.Context) chan ScanResult {
|
|||||||
w.ProgressTickIntervalS = 2
|
w.ProgressTickIntervalS = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
ticker := time.NewTicker(time.Duration(w.ProgressTickIntervalS) * time.Second)
|
|
||||||
|
|
||||||
// We need to emit progress events, hence we create a routine which buffers
|
// We need to emit progress events, hence we create a routine which buffers
|
||||||
// the list of files to be hashed, counts the total number of
|
// the list of files to be hashed, counts the total number of
|
||||||
// bytes to hash, and once no more files need to be hashed (chan gets closed),
|
// bytes to hash, and once no more files need to be hashed (chan gets closed),
|
||||||
@ -188,17 +186,17 @@ func (w *walker) walk(ctx context.Context) chan ScanResult {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ticker := time.NewTicker(time.Duration(w.ProgressTickIntervalS) * time.Second)
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-done:
|
case <-done:
|
||||||
emitProgressEvent()
|
emitProgressEvent()
|
||||||
l.Debugln(w, "Walk progress done", w.Folder, w.Subs, w.Matcher)
|
l.Debugln(w, "Walk progress done", w.Folder, w.Subs, w.Matcher)
|
||||||
ticker.Stop()
|
|
||||||
return
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
emitProgressEvent()
|
emitProgressEvent()
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
ticker.Stop()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user