Add enable_sign to the basic storage struct.

Can enable sign for every driver now.

Bug: When sign enabled, in download page, Copy link doesn't contain a sign.

(Not done yet)
pull/3924/head
Season Shi 2023-03-23 18:24:04 +08:00
parent 6348baf547
commit 8f6c25fbe4
No known key found for this signature in database
GPG Key ID: 024D6B1E861D7FB0
4 changed files with 12 additions and 13 deletions

View File

@ -8,7 +8,6 @@ import (
type Addition struct {
driver.RootPath
Thumbnail bool `json:"thumbnail" required:"true" help:"enable thumbnail"`
Sign bool `json:"sign" default:"false" required:"false" help:"enable sign"`
ShowHidden bool `json:"show_hidden" default:"true" required:"false" help:"show hidden directories and files"`
MkdirPerm string `json:"mkdir_perm" default:"777"`
}

View File

@ -15,6 +15,11 @@ type Storage struct {
Disabled bool `json:"disabled"` // if disabled
Sort
Proxy
Sign
}
type Sign struct {
EnableSign bool `json:"enable_sign"`
}
type Sort struct {

View File

@ -122,9 +122,14 @@ func getMainItems(config driver.Config) []driver.Item {
Type: conf.TypeSelect,
Options: "front,back",
})
items = append(items, driver.Item{
Name: "enable_sign",
Type: conf.TypeBool,
Default: "false",
Required: true,
})
return items
}
func getAdditionalItems(t reflect.Type, defaultRoot string) []driver.Item {
var items []driver.Item
for i := 0; i < t.NumField(); i++ {

View File

@ -2,21 +2,11 @@ package sign
import (
"github.com/alist-org/alist/v3/internal/op"
json "github.com/json-iterator/go"
)
type signType struct {
Sign bool `json:"sign"`
}
func IsStorageSigned(rawPath string) bool {
var jsonData signType
storage := op.GetBalancedStorage(rawPath).GetStorage()
err := json.Unmarshal([]byte(storage.Addition), &jsonData)
if err != nil {
return false
}
if jsonData.Sign == true {
if storage.EnableSign == true {
return true
}
return false