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 {
|
type Addition struct {
|
||||||
driver.RootPath
|
driver.RootPath
|
||||||
Thumbnail bool `json:"thumbnail" required:"true" help:"enable thumbnail"`
|
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"`
|
ShowHidden bool `json:"show_hidden" default:"true" required:"false" help:"show hidden directories and files"`
|
||||||
MkdirPerm string `json:"mkdir_perm" default:"777"`
|
MkdirPerm string `json:"mkdir_perm" default:"777"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,11 @@ type Storage struct {
|
||||||
Disabled bool `json:"disabled"` // if disabled
|
Disabled bool `json:"disabled"` // if disabled
|
||||||
Sort
|
Sort
|
||||||
Proxy
|
Proxy
|
||||||
|
Sign
|
||||||
|
}
|
||||||
|
|
||||||
|
type Sign struct {
|
||||||
|
EnableSign bool `json:"enable_sign"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Sort struct {
|
type Sort struct {
|
||||||
|
|
|
@ -122,9 +122,14 @@ func getMainItems(config driver.Config) []driver.Item {
|
||||||
Type: conf.TypeSelect,
|
Type: conf.TypeSelect,
|
||||||
Options: "front,back",
|
Options: "front,back",
|
||||||
})
|
})
|
||||||
|
items = append(items, driver.Item{
|
||||||
|
Name: "enable_sign",
|
||||||
|
Type: conf.TypeBool,
|
||||||
|
Default: "false",
|
||||||
|
Required: true,
|
||||||
|
})
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAdditionalItems(t reflect.Type, defaultRoot string) []driver.Item {
|
func getAdditionalItems(t reflect.Type, defaultRoot string) []driver.Item {
|
||||||
var items []driver.Item
|
var items []driver.Item
|
||||||
for i := 0; i < t.NumField(); i++ {
|
for i := 0; i < t.NumField(); i++ {
|
||||||
|
|
|
@ -2,21 +2,11 @@ package sign
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/alist-org/alist/v3/internal/op"
|
"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 {
|
func IsStorageSigned(rawPath string) bool {
|
||||||
var jsonData signType
|
|
||||||
storage := op.GetBalancedStorage(rawPath).GetStorage()
|
storage := op.GetBalancedStorage(rawPath).GetStorage()
|
||||||
err := json.Unmarshal([]byte(storage.Addition), &jsonData)
|
if storage.EnableSign == true {
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if jsonData.Sign == true {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue