fix: copy tasks using multi-thread downloader can't be canceled (#5028)

#4981 related
This commit is contained in:
Andy Hsu
2023-08-19 14:06:59 +08:00
committed by GitHub
parent ed550594da
commit 1e3950c847
4 changed files with 51 additions and 137 deletions

View File

@ -7,14 +7,15 @@ import (
"bytes"
"context"
"fmt"
"github.com/alist-org/alist/v3/pkg/http_range"
"github.com/sirupsen/logrus"
"golang.org/x/exp/slices"
"io"
"io/ioutil"
"net/http"
"sync"
"testing"
"github.com/alist-org/alist/v3/pkg/http_range"
"github.com/sirupsen/logrus"
"golang.org/x/exp/slices"
)
var buf22MB = make([]byte, 1024*1024*22)
@ -55,7 +56,7 @@ func TestDownloadOrder(t *testing.T) {
if err != nil {
t.Fatalf("expect no error, got %v", err)
}
resultBuf, err := io.ReadAll(*readCloser)
resultBuf, err := io.ReadAll(readCloser)
if err != nil {
t.Fatalf("expect no error, got %v", err)
}
@ -111,7 +112,7 @@ func TestDownloadSingle(t *testing.T) {
if err != nil {
t.Fatalf("expect no error, got %v", err)
}
resultBuf, err := io.ReadAll(*readCloser)
resultBuf, err := io.ReadAll(readCloser)
if err != nil {
t.Fatalf("expect no error, got %v", err)
}