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) {
|
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() {
|
||||||
Path: prefix,
|
err = d.client.List(&upyun.GetObjectsConfig{
|
||||||
ObjectsChan: objsChan,
|
Path: prefix,
|
||||||
MaxListObjects: 0,
|
ObjectsChan: objsChan,
|
||||||
MaxListLevel: 1,
|
MaxListObjects: 0,
|
||||||
}
|
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)
|
||||||
|
|
|
@ -11,8 +11,8 @@ 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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = driver.Config{
|
var config = driver.Config{
|
||||||
|
|
Loading…
Reference in New Issue