Skip to content

Commit

Permalink
fix(net): close of closed channel (AlistGo#7529)
Browse files Browse the repository at this point in the history
  • Loading branch information
j2rong4cn authored Nov 21, 2024
1 parent 25c5e07 commit 4c0cffd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/net/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"fmt"
"github.com/alist-org/alist/v3/pkg/utils"
"io"
"math"
"net/http"
Expand All @@ -13,6 +12,8 @@ import (
"sync"
"time"

"github.com/alist-org/alist/v3/pkg/utils"

"github.com/alist-org/alist/v3/pkg/http_range"
"github.com/aws/aws-sdk-go/aws/awsutil"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -168,6 +169,9 @@ func (d *downloader) sendChunkTask() *chunk {

// when the final reader Close, we interrupt
func (d *downloader) interrupt() error {
if d.chunkChannel == nil {
return nil
}
d.cancel()
if d.written != d.params.Range.Length {
log.Debugf("Downloader interrupt before finish")
Expand All @@ -177,6 +181,7 @@ func (d *downloader) interrupt() error {
}
defer func() {
close(d.chunkChannel)
d.chunkChannel = nil
for _, buf := range d.bufs {
buf.Close()
}
Expand Down

0 comments on commit 4c0cffd

Please sign in to comment.