Skip to content

Commit

Permalink
🐛 set up locks more correctly (#635)
Browse files Browse the repository at this point in the history
Signed-off-by: Shawn Hurley <[email protected]>
  • Loading branch information
shawn-hurley authored Feb 10, 2025
1 parent 5945e60 commit 41b33f2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kai_analyzer_rpc/pkg/service/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ func (a *Analyzer) Analyze(args Args, response *Response) error {

func (a *Analyzer) setCache(rulesets []konveyor.RuleSet) {
a.cacheMutex.Lock()
defer a.cacheMutex.Unlock()
a.cache = map[string][]cacheValue{}
a.cacheMutex.Unlock()

a.updateCache(rulesets, nil)
a.addRulesetsToCache(rulesets)
}

func (a *Analyzer) updateCache(rulesets []konveyor.RuleSet, includedPaths []string) {
Expand All @@ -297,6 +297,10 @@ func (a *Analyzer) updateCache(rulesets []konveyor.RuleSet, includedPaths []stri
if includedPaths != nil {
a.invalidateCachePerFile(includedPaths)
}
a.addRulesetsToCache(rulesets)
}

func (a *Analyzer) addRulesetsToCache(rulesets []konveyor.RuleSet) {

for _, r := range rulesets {
for violationName, v := range r.Violations {
Expand Down

0 comments on commit 41b33f2

Please sign in to comment.