Skip to content

Commit

Permalink
Remove deleted repos from searchresult (#21512)
Browse files Browse the repository at this point in the history
This prevents a 500 response, because null pointer exceptions in
rendering the template.
This happends bc the repoId is not in the repoMap because it is delete

fix #19076

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
  • Loading branch information
4 people authored Oct 22, 2022
1 parent 2c77d4b commit 69fcca2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions routers/web/explore/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ func Code(ctx *context.Context) {
}

ctx.Data["RepoMaps"] = repoMaps

if len(loadRepoIDs) != len(repoMaps) {
// Remove deleted repos from search results
cleanedSearchResults := make([]*code_indexer.Result, 0, len(repoMaps))
for _, sr := range searchResults {
if _, found := repoMaps[sr.RepoID]; found {
cleanedSearchResults = append(cleanedSearchResults, sr)
}
}

searchResults = cleanedSearchResults
}
}

ctx.Data["SearchResults"] = searchResults
Expand Down

0 comments on commit 69fcca2

Please sign in to comment.