Only use an open handle during the traversal section, not while waiting for subdirs

main
Mari 4 years ago
parent 164d33c27f
commit f3a9ccc8a1
  1. 4
      drive-demuxer.go

@ -274,6 +274,7 @@ func (s *Step) AreFilesIdentical(child string) bool {
func (s *Step) Walk() { func (s *Step) Walk() {
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
s.OpenHandles <- 1
children := s.ListChildren() children := s.ListChildren()
s.Bar.AddTotal(int64(len(children))) s.Bar.AddTotal(int64(len(children)))
for _, child := range children { for _, child := range children {
@ -328,10 +329,8 @@ func (s *Step) Walk() {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer func() { defer func() {
<-s.OpenHandles
wg.Done() wg.Done()
}() }()
s.OpenHandles <- 1
substep.Walk() substep.Walk()
s.RemoveInputDirs(child) s.RemoveInputDirs(child)
s.Bar.Increment() s.Bar.Increment()
@ -345,6 +344,7 @@ func (s *Step) Walk() {
} }
} }
<-s.OpenHandles
wg.Wait() wg.Wait()
} }

Loading…
Cancel
Save