summaryrefslogtreecommitdiffstats
path: root/routers/web/explore
diff options
context:
space:
mode:
authorRaymond <raymond@k3n.nl>2022-10-22 11:23:20 +0200
committerGitHub <noreply@github.com>2022-10-22 17:23:20 +0800
commit69fcca2d4564f706fa41280895e3a20d81740598 (patch)
treecc021e2f01bbeba0f79fff48862bdd344d69a813 /routers/web/explore
parent2c77d4b19505f8eede4d2cb5d415f6440d6cffc2 (diff)
downloadgitea-69fcca2d4564f706fa41280895e3a20d81740598.tar.gz
gitea-69fcca2d4564f706fa41280895e3a20d81740598.zip
Remove deleted repos from searchresult (#21512)
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>
Diffstat (limited to 'routers/web/explore')
-rw-r--r--routers/web/explore/code.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/routers/web/explore/code.go b/routers/web/explore/code.go
index 2357b34fd0..38474255d1 100644
--- a/routers/web/explore/code.go
+++ b/routers/web/explore/code.go
@@ -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