mirror of https://github.com/Xhofe/alist
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
parent
6348baf547
commit
8f6c25fbe4
|
@ -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"`
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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++ {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue