Skip to content

Commit

Permalink
feat(index): add disable index option for storages (#7730)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lanfei authored Dec 30, 2024
1 parent 040dc14 commit ed149be
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/model/storage.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package model

import "time"
import (
"time"
)

type Storage struct {
ID uint `json:"id" gorm:"primaryKey"` // unique key
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions internal/op/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions internal/search/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ed149be

Please sign in to comment.