From 586af790cbf718e1c701332d962cf622bfd179e5 Mon Sep 17 00:00:00 2001 From: Jealous Date: Sat, 28 Dec 2024 17:20:40 +0800 Subject: [PATCH] feat(index): add `disable index` option for storages --- internal/model/storage.go | 5 ++++- internal/op/driver.go | 6 ++++++ internal/search/build.go | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/internal/model/storage.go b/internal/model/storage.go index 14bcf45f6e2..e3c7e1f9731 100644 --- a/internal/model/storage.go +++ b/internal/model/storage.go @@ -1,6 +1,8 @@ package model -import "time" +import ( + "time" +) type Storage struct { ID uint `json:"id" gorm:"primaryKey"` // unique key @@ -13,6 +15,7 @@ type Storage struct { Remark string `json:"remark"` Modified time.Time `json:"modified"` Disabled bool `json:"disabled"` // if disabled + DisableIndex bool `json:"disable_index"` EnableSign bool `json:"enable_sign"` Sort Proxy diff --git a/internal/op/driver.go b/internal/op/driver.go index 4f10e8e23c6..41b6f6d42c7 100644 --- a/internal/op/driver.go +++ b/internal/op/driver.go @@ -133,6 +133,12 @@ func getMainItems(config driver.Config) []driver.Item { Type: conf.TypeSelect, Options: "front,back", }) + items = append(items, driver.Item{ + Name: "disable_index", + Type: conf.TypeBool, + Default: "false", + Required: true, + }) items = append(items, driver.Item{ Name: "enable_sign", Type: conf.TypeBool, diff --git a/internal/search/build.go b/internal/search/build.go index 9865b2988a1..2888c1f45bb 100644 --- a/internal/search/build.go +++ b/internal/search/build.go @@ -157,6 +157,11 @@ func BuildIndex(ctx context.Context, indexPaths, ignorePaths []string, maxDepth return filepath.SkipDir } } + if storage, _, err := op.GetStorageAndActualPath(indexPath); err == nil { + if storage.GetStorage().DisableIndex { + return filepath.SkipDir + } + } // ignore root if indexPath == "/" { return nil