fix(USS): resolve driver problem (#2942)

* remove:"Endpoint" and "CustomHost" are the same thing, remove "CustomHost"

* fix: file download url error

* fix: too many file get list error

Co-authored-by: wangwuxuan <wangwuxuan@163.com>
pull/2956/head
wangwuxuan2011 2023-01-08 16:30:05 +08:00 committed by GitHub
parent 7c3ea193ff
commit 40ef233d24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 17 deletions

View File

@ -44,17 +44,18 @@ func (d *USS) Drop(ctx context.Context) error {
func (d *USS) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) { func (d *USS) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
prefix := getKey(dir.GetPath(), true) prefix := getKey(dir.GetPath(), true)
objsChan := make(chan *upyun.FileInfo, 10) objsChan := make(chan *upyun.FileInfo, 10)
var err error
cfg := &upyun.GetObjectsConfig{ go func() {
err = d.client.List(&upyun.GetObjectsConfig{
Path: prefix, Path: prefix,
ObjectsChan: objsChan, ObjectsChan: objsChan,
MaxListObjects: 0, MaxListObjects: 0,
MaxListLevel: 1, MaxListLevel: 1,
} })
if err := d.client.List(cfg); err != nil { }()
if err != nil {
return nil, err return nil, err
} }
res := make([]model.Obj, 0) res := make([]model.Obj, 0)
for obj := range objsChan { for obj := range objsChan {
t := obj.Time t := obj.Time
@ -66,16 +67,13 @@ func (d *USS) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]m
} }
res = append(res, &f) res = append(res, &f)
} }
return res, nil return res, err
} }
func (d *USS) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) { func (d *USS) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
key := getKey(file.GetPath(), false) key := getKey(file.GetPath(), false)
host := d.CustomHost host := d.Endpoint
if host == "" { if !strings.Contains(host, "://") { //判断是否包含协议头否则https
host = d.Endpoint
}
if strings.Contains(host, "://") {
host = "https://" + host host = "https://" + host
} }
u := fmt.Sprintf("%s/%s", host, key) u := fmt.Sprintf("%s/%s", host, key)

View File

@ -11,7 +11,7 @@ type Addition struct {
Endpoint string `json:"endpoint" required:"true"` Endpoint string `json:"endpoint" required:"true"`
OperatorName string `json:"operator_name" required:"true"` OperatorName string `json:"operator_name" required:"true"`
OperatorPassword string `json:"operator_password" required:"true"` OperatorPassword string `json:"operator_password" required:"true"`
CustomHost string `json:"custom_host"` //CustomHost string `json:"custom_host"` //Endpoint与CustomHost作用相同去除
SignURLExpire int `json:"sign_url_expire" type:"number" default:"4"` SignURLExpire int `json:"sign_url_expire" type:"number" default:"4"`
} }