diff --git a/internal/net/request.go b/internal/net/request.go index 088ff66ab4f..c0f547ba8c3 100644 --- a/internal/net/request.go +++ b/internal/net/request.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "fmt" - "github.com/alist-org/alist/v3/pkg/utils" "io" "math" "net/http" @@ -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" @@ -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") @@ -177,6 +181,7 @@ func (d *downloader) interrupt() error { } defer func() { close(d.chunkChannel) + d.chunkChannel = nil for _, buf := range d.bufs { buf.Close() }