mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-07-19 01:48:42 +08:00
net: 支持1并发 分片下载
This commit is contained in:
@ -171,7 +171,7 @@ func (d *downloader) download() (io.ReadCloser, error) {
|
||||
|
||||
log.Debugf("cfgConcurrency:%d", d.cfg.Concurrency)
|
||||
|
||||
if d.cfg.Concurrency == 1 {
|
||||
if maxPart == 1 {
|
||||
if d.cfg.ConcurrencyLimit != nil {
|
||||
go func() {
|
||||
<-d.ctx.Done()
|
||||
|
@ -19,7 +19,7 @@ func GetRangeReadCloserFromLink(size int64, link *model.Link) (model.RangeReadCl
|
||||
return nil, fmt.Errorf("can't create RangeReadCloser since URL is empty in link")
|
||||
}
|
||||
rangeReaderFunc := func(ctx context.Context, r http_range.Range) (io.ReadCloser, error) {
|
||||
if link.Concurrency != 0 || link.PartSize != 0 {
|
||||
if link.Concurrency > 0 || link.PartSize > 0 {
|
||||
header := net.ProcessHeader(nil, link.Header)
|
||||
down := net.NewDownloader(func(d *net.Downloader) {
|
||||
d.Concurrency = link.Concurrency
|
||||
|
@ -41,7 +41,7 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.
|
||||
RangeReadCloserIF: link.RangeReadCloser,
|
||||
Limiter: stream.ServerDownloadLimit,
|
||||
})
|
||||
} else if link.Concurrency != 0 || link.PartSize != 0 {
|
||||
} else if link.Concurrency > 0 || link.PartSize > 0 {
|
||||
attachHeader(w, file)
|
||||
size := file.GetSize()
|
||||
rangeReader := func(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error) {
|
||||
|
Reference in New Issue
Block a user