mirror of https://github.com/Xhofe/alist
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
parent
7c3ea193ff
commit
40ef233d24
|
@ -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)
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue