Jelajahi Sumber

Simplify Search/Index service config

Remove 'Do' config key and check for configured URLs for each operation
as necessary.
Achilleas Koutsou 6 tahun lalu
induk
melakukan
bfaa5047b7

+ 1 - 1
cmd/serv.go

@@ -273,7 +273,7 @@ func runServ(c *cli.Context) error {
 		cmd = []string{verb, repoFullName}
 	}
 	runGit(cmd, requestMode, user, owner, repo)
-	if setting.Search.Do && (requestMode == models.ACCESS_MODE_WRITE) {
+	if setting.Search.IndexURL != "" && (requestMode == models.ACCESS_MODE_WRITE) {
 		models.StartIndexing(user, owner, repo)
 	}
 	return nil

+ 1 - 1
models/models_gin.go

@@ -16,7 +16,7 @@ import (
 // StartIndexing sends an indexing request to the configured indexing service
 // for a repository.
 func StartIndexing(user, owner *User, repo *Repository) {
-	if !setting.Search.Do {
+	if setting.Search.IndexURL == "" {
 		log.Trace("Indexing not enabled")
 		return
 	}

+ 1 - 1
models/repo_editor.go

@@ -194,7 +194,7 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
 		return fmt.Errorf("git push origin %s: %v", opts.NewBranch, err)
 	}
 
-	if setting.Search.Do {
+	if setting.Search.IndexURL != "" {
 		StartIndexing(doer, repo.MustOwner(), repo)
 	}
 	return nil

+ 0 - 1
pkg/setting/setting.go

@@ -331,7 +331,6 @@ var (
 	HasRobotsTxt bool
 
 	Search struct {
-		Do        bool
 		IndexURL  string `ini:"INDEX_URL"`
 		SearchURL string `ini:"SEARCH_URL"`
 	}

+ 1 - 1
routes/api/v1/search/general.go

@@ -16,7 +16,7 @@ func Search(c *context.APIContext) {
 		c.Status(http.StatusUnauthorized)
 		return
 	}
-	if !setting.Search.Do {
+	if setting.Search.SearchURL == "" {
 		c.Status(http.StatusNotImplemented)
 		return
 	}

+ 1 - 1
routes/api/v1/search/suggest.go

@@ -12,7 +12,7 @@ import (
 )
 
 func Suggest(c *context.APIContext) {
-	if !setting.Search.Do {
+	if setting.Search.SearchURL == "" {
 		c.Status(http.StatusNotImplemented)
 		return
 	}

+ 1 - 1
routes/search.go

@@ -20,7 +20,7 @@ const (
 )
 
 func Search(c *context.Context, keywords string, sType int64) ([]byte, error) {
-	if !setting.Search.Do {
+	if setting.Search.SearchURL == "" {
 		c.Status(http.StatusNotImplemented)
 		return nil, fmt.Errorf("Extended search not implemented")
 	}