fix(uss): close of closed channel (close #2847 #2896)

* fix(uss): close of closed channel

* fix(uss): close of closed channel

Co-authored-by: zxdstyle <xiangdong.zhu@maitang001.com>
pull/2906/head
zxdstyle 2023-01-04 21:43:47 +08:00 committed by GitHub
parent 1c8d895fc0
commit 428e59a844
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 12 deletions

View File

@ -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() {
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
@ -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) {