feat: add a switch to enable auto update index (close #2930)

pull/2938/head
BoYanZh 2023-01-07 00:59:30 +08:00 committed by GitHub
parent cf5714ba73
commit 1c453ae147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -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},

View File

@ -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"

View File

@ -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) {