Less confusing waitgroup positioning

This commit is contained in:
Dane Everitt 2020-07-16 21:53:05 -07:00
parent f3c8220bd9
commit d262c12b43
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -41,8 +41,6 @@ func newPooledWalker(fs *Filesystem) *PooledFileWalker {
// Process a given path by calling the callback function for all of the files and directories within // Process a given path by calling the callback function for all of the files and directories within
// the path, and then dropping into any directories that we come across. // the path, and then dropping into any directories that we come across.
func (w *PooledFileWalker) process(path string) error { func (w *PooledFileWalker) process(path string) error {
defer w.wg.Done()
p, err := w.Filesystem.SafePath(path) p, err := w.Filesystem.SafePath(path)
if err != nil { if err != nil {
return err return err
@ -82,6 +80,7 @@ func (w *PooledFileWalker) process(path string) error {
func (w *PooledFileWalker) push(path string) { func (w *PooledFileWalker) push(path string) {
w.wg.Add(1) w.wg.Add(1)
w.pool.Submit(func() { w.pool.Submit(func() {
defer w.wg.Done()
w.process(path) w.process(path)
}) })
} }