mirror of https://github.com/Xhofe/alist
* fix(uss): close of closed channel * fix(uss): close of closed channel Co-authored-by: zxdstyle <xiangdong.zhu@maitang001.com>pull/2906/head
parent
1c8d895fc0
commit
428e59a844
|
@ -44,19 +44,17 @@ 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
|
|
||||||
defer close(objsChan)
|
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
|
||||||
|
@ -68,7 +66,7 @@ func (d *USS) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]m
|
||||||
}
|
}
|
||||||
res = append(res, &f)
|
res = append(res, &f)
|
||||||
}
|
}
|
||||||
return res, err
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|
Loading…
Reference in New Issue