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) {
prefix := getKey(dir.GetPath(), true)
objsChan := make(chan *upyun.FileInfo, 10)
cfg := &upyun.GetObjectsConfig{
Path: prefix,
ObjectsChan: objsChan,
MaxListObjects: 0,
MaxListLevel: 1,
}
if err := d.client.List(cfg); err != nil {
var err error
go func() {
err = d.client.List(&upyun.GetObjectsConfig{
Path: prefix,
ObjectsChan: objsChan,
MaxListObjects: 0,
MaxListLevel: 1,
})
}()
if err != nil {
return nil, err
}
res := make([]model.Obj, 0)
for obj := range objsChan {
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)
}
return res, nil
return res, err
}
func (d *USS) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
key := getKey(file.GetPath(), false)
host := d.CustomHost
if host == "" {
host = d.Endpoint
}
if strings.Contains(host, "://") {
host := d.Endpoint
if !strings.Contains(host, "://") { //判断是否包含协议头否则https
host = "https://" + host
}
u := fmt.Sprintf("%s/%s", host, key)

View File

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