Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Dec 24, 2024
1 parent 351c47b commit 32e8745
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions internal/protocol/http/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (f *Fetcher) fetch() {
var ctx context.Context
ctx, f.cancel = context.WithCancel(context.Background())
f.eg, _ = errgroup.WithContext(ctx)
fetchResults := make([]*fetchResult, len(f.chunks))
chunkErrs := make([]error, len(f.chunks))
for i := 0; i < len(f.chunks); i++ {
i := i
f.eg.Go(func() error {
Expand All @@ -271,10 +271,7 @@ func (f *Fetcher) fetch() {
if errors.Is(err, context.Canceled) {
return err
}
fr := &fetchResult{
err: err,
}
fetchResults[i] = fr
chunkErrs[i] = err
return nil
})
}
Expand All @@ -286,9 +283,9 @@ func (f *Fetcher) fetch() {
return
}
// check all fetch results, if any error, return
for _, fr := range fetchResults {
if fr.err != nil {
err = fr.err
for _, chunkErr := range chunkErrs {
if chunkErr != nil {
err = chunkErr
break
}
}
Expand Down

0 comments on commit 32e8745

Please sign in to comment.