Repository: AlistGo/alist (language: go)

Issue:
Add a switch on auto update index hook
### Please make sure of the following things

- [X] I have read the [documentation](https://alist.nn.ci).
- [X] I'm sure there are no duplicate issues or discussions.
- [X] I'm sure this feature is not implemented.
- [X] I'm sure it's a reasonable and popular requirement.

### Description of the feature / 需求描述

Now `AutoUpdate` is pre-defined in codes, I think it is better to add a switch to let the user decide turn it on or not.
For a large directory, the recursive auto update may causing too many db operations.

### Suggested solution / 实现思路

_No response_

### Additional context / 附件

_No response_


Discussion / hints:

Fix patch:
diff --git a/internal/bootstrap/data/setting.go b/internal/bootstrap/data/setting.go
index b7980ca185b..9057b4f2632 100644
--- a/internal/bootstrap/data/setting.go
+++ b/internal/bootstrap/data/setting.go
@@ -144,6 +144,7 @@ func InitialSettings() []model.SettingItem {
 		// single settings
 		{Key: conf.Token, Value: token, Type: conf.TypeString, Group: model.SINGLE, Flag: model.PRIVATE},
 		{Key: conf.SearchIndex, Value: "none", Type: conf.TypeSelect, Options: "database,bleve,none", Group: model.INDEX},
+		{Key: conf.AutoUpdateIndex, Value: "false", Type: conf.TypeBool, Group: model.INDEX},
 		{Key: conf.IgnorePaths, Value: "", Type: conf.TypeText, Group: model.INDEX, Flag: model.PRIVATE, Help: `one path per line`},
 		{Key: conf.IndexProgress, Value: "{}", Type: conf.TypeText, Group: model.SINGLE, Flag: model.PRIVATE},
 
diff --git a/internal/conf/const.go b/internal/conf/const.go
index df7ef08f4b3..6a75634efa6 100644
--- a/internal/conf/const.go
+++ b/internal/conf/const.go
@@ -42,9 +42,10 @@ const (
 	FilenameCharMapping = "filename_char_mapping"
 
 	// index
-	SearchIndex = "search_index"
-	IndexPaths  = "index_paths"
-	IgnorePaths = "ignore_paths"
+	SearchIndex     = "search_index"
+	AutoUpdateIndex = "auto_update_index"
+	IndexPaths      = "index_paths"
+	IgnorePaths     = "ignore_paths"
 
 	// aria2
 	Aria2Uri    = "aria2_uri"
diff --git a/internal/search/build.go b/internal/search/build.go
index 25af1a567eb..399653a9a2a 100644
--- a/internal/search/build.go
+++ b/internal/search/build.go
@@ -13,6 +13,7 @@ import (
 	"github.com/alist-org/alist/v3/internal/model"
 	"github.com/alist-org/alist/v3/internal/op"
 	"github.com/alist-org/alist/v3/internal/search/searcher"
+	"github.com/alist-org/alist/v3/internal/setting"
 	"github.com/alist-org/alist/v3/pkg/mq"
 	"github.com/alist-org/alist/v3/pkg/utils"
 	mapset "github.com/deckarep/golang-set/v2"
@@ -164,7 +165,7 @@ func Config(ctx context.Context) searcher.Config {
 }
 
 func Update(parent string, objs []model.Obj) {
-	if instance == nil || !instance.Config().AutoUpdate || Running.Load() {
+	if instance == nil || !instance.Config().AutoUpdate || !setting.GetBool(conf.AutoUpdateIndex) || Running.Load() {
 		return
 	}
 	if isIgnorePath(parent) {


Test patch: