refactor: don't use a buffered chan
This commit is contained in:
parent
b46e12b972
commit
d5e2770135
10
api/s5/s5.go
10
api/s5/s5.go
|
@ -875,7 +875,8 @@ func (s *S5API) accountPinManifest(jc jape.Context, userId uint, cid *encoding.C
|
||||||
|
|
||||||
q := queue.NewPool(10)
|
q := queue.NewPool(10)
|
||||||
defer q.Release()
|
defer q.Release()
|
||||||
rets := make(chan pinQueueResult, len(cids))
|
rets := make(chan pinQueueResult)
|
||||||
|
defer close(rets)
|
||||||
|
|
||||||
results := make(map[string]pinResult, len(cids))
|
results := make(map[string]pinResult, len(cids))
|
||||||
|
|
||||||
|
@ -909,10 +910,6 @@ func (s *S5API) accountPinManifest(jc jape.Context, userId uint, cid *encoding.C
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
q.Wait()
|
|
||||||
close(rets)
|
|
||||||
}()
|
|
||||||
|
|
||||||
for ret := range rets {
|
for ret := range rets {
|
||||||
b64, err := ret.cid.ToBase64Url()
|
b64, err := ret.cid.ToBase64Url()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -925,6 +922,9 @@ func (s *S5API) accountPinManifest(jc jape.Context, userId uint, cid *encoding.C
|
||||||
error: ret.error,
|
error: ret.error,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
q.Wait()
|
||||||
|
|
||||||
jc.Encode(&results)
|
jc.Encode(&results)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue