Skip to content

Commit

Permalink
Fixed logic error when a new module that has been removed from the vc…
Browse files Browse the repository at this point in the history
…s system

Signed-off-by: AbstractionFactory <[email protected]>
  • Loading branch information
abstractionfactory committed Sep 3, 2024
1 parent 25dfa08 commit 7620edb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backend/internal/moduleindex/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func (g generator) generate(ctx context.Context, moduleList []module.Addr, block

moduleIndexPath := path.Join(moduleAddr.Namespace, moduleAddr.Name, moduleAddr.TargetSystem, "index.json")
entry := modules.GetModule(moduleAddr.Addr)
needsAdd := false
if entry == nil {
entry = &Module{
Addr: moduleAddr,
Expand All @@ -205,9 +206,7 @@ func (g generator) generate(ctx context.Context, moduleList []module.Addr, block
IsBlocked: blocked,
BlockedReason: blockedReason,
}
lock.Lock()
modulesToAdd = append(modulesToAdd, entry)
lock.Unlock()
needsAdd = true
}

if entry.IsBlocked != blocked {
Expand Down Expand Up @@ -330,6 +329,11 @@ func (g generator) generate(ctx context.Context, moduleList []module.Addr, block
return fmt.Errorf("failed to remove module from search index (%w)", err)
}
} else {
if needsAdd {
lock.Lock()
modulesToAdd = append(modulesToAdd, entry)
lock.Unlock()
}
versionListing, err := json.Marshal(entry)
if err != nil {
return fmt.Errorf("failed to marshal module index for %s (%w)", entry.Addr, err)
Expand Down

0 comments on commit 7620edb

Please sign in to comment.