diff options
author | Lauris BH <lauris@nix.lv> | 2022-01-27 10:30:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-27 10:30:51 +0200 |
commit | 8038610a4279862a87e630e4f1d1077c510f9d15 (patch) | |
tree | 802489f8ddde899e76643ea157f9020f12ca1490 /routers/web/repo/search.go | |
parent | 2649eddcf0bb1190abab49c9d79ce19bfcf19e87 (diff) | |
download | gitea-8038610a4279862a87e630e4f1d1077c510f9d15.tar.gz gitea-8038610a4279862a87e630e4f1d1077c510f9d15.zip |
Automatically pause queue if index service is unavailable (#15066)
* Handle keyword search error when issue indexer service is not available
* Implement automatic disabling and resume of code indexer queue
Diffstat (limited to 'routers/web/repo/search.go')
-rw-r--r-- | routers/web/repo/search.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/routers/web/repo/search.go b/routers/web/repo/search.go index 67539c3d7e..e33fe38dea 100644 --- a/routers/web/repo/search.go +++ b/routers/web/repo/search.go @@ -30,11 +30,16 @@ func Search(ctx *context.Context) { queryType := ctx.FormTrim("t") isMatch := queryType == "match" - total, searchResults, searchResultLanguages, err := code_indexer.PerformSearch([]int64{ctx.Repo.Repository.ID}, + total, searchResults, searchResultLanguages, err := code_indexer.PerformSearch(ctx, []int64{ctx.Repo.Repository.ID}, language, keyword, page, setting.UI.RepoSearchPagingNum, isMatch) if err != nil { - ctx.ServerError("SearchResults", err) - return + if code_indexer.IsAvailable() { + ctx.ServerError("SearchResults", err) + return + } + ctx.Data["CodeIndexerUnavailable"] = true + } else { + ctx.Data["CodeIndexerUnavailable"] = !code_indexer.IsAvailable() } ctx.Data["Keyword"] = keyword ctx.Data["Language"] = language |