Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
refactor(analyzer) defer cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
masahiro331 committed Oct 23, 2021
1 parent 48b2526 commit 4599011
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ func (a Analyzer) AnalyzeFile(ctx context.Context, wg *sync.WaitGroup, limit *se
return xerrors.Errorf("unable to open a file (%s): %w", filePath, err)
}
defer func() {
wg.Wait()
err = cleaner()
err := cleaner()
if err != nil {
log.Logger.Warn("Clean temp directory error: %s", err)
}
}()

if err = limit.Acquire(ctx, 1); err != nil {
Expand All @@ -223,6 +225,8 @@ func (a Analyzer) AnalyzeFile(ctx context.Context, wg *sync.WaitGroup, limit *se
result.Merge(ret)
}(d, AnalysisTarget{Dir: dir, FilePath: filePath, ContentReader: rc})
}
wg.Wait()

return nil
}

Expand Down

0 comments on commit 4599011

Please sign in to comment.