feat(index): add `disable index` option for storages (#7730)

pull/7754/head
Jealous 2024-12-30 22:52:55 +08:00 committed by GitHub
parent 040dc14ee6
commit ed149be84b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 1 deletions

View File

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

View File

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

View File

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