@@ -2,6 +2,7 @@ package internal
2
2
3
3
import (
4
4
"fmt"
5
+ "net/http"
5
6
"os"
6
7
"path/filepath"
7
8
"sync"
@@ -51,11 +52,11 @@ func BatchDownload(entries []DownloadEntry, numLinks int, connectionsPerLink int
51
52
ProxyURL : proxyURL ,
52
53
}
53
54
progressCh := make (chan int64 )
54
- client := createHTTPClient (config .Timeout , config .KATimeout , config .ProxyURL )
55
+ useHighThreadMode := config .Connections > 6
56
+ client := createHTTPClient (config .Timeout , config .KATimeout , config .ProxyURL , useHighThreadMode )
55
57
fileSize , err := getFileSize (config .URL , config .UserAgent , client )
56
58
57
59
if err == ErrRangeRequestsNotSupported {
58
- // file size unknown, so can't show progress; so track bytes downloaded
59
60
logger .Debug ().Str ("url" , entry .URL ).Msg ("Range requests not supported, using simple download" )
60
61
progressManager .Register (entry .OutputPath , - 1 ) // -1 means unknown size
61
62
} else if err != nil {
@@ -82,9 +83,8 @@ func BatchDownload(entries []DownloadEntry, numLinks int, connectionsPerLink int
82
83
if err == ErrRangeRequestsNotSupported {
83
84
err = performSimpleDownload (entry .URL , entry .OutputPath , client , config .UserAgent , progressCh )
84
85
} else {
85
- err = downloadWithProgress (config , fileSize , progressCh )
86
+ err = downloadWithProgress (config , client , fileSize , progressCh )
86
87
}
87
- // close(progressCh)
88
88
progressWg .Wait ()
89
89
90
90
if err != nil {
@@ -110,9 +110,9 @@ func BatchDownload(entries []DownloadEntry, numLinks int, connectionsPerLink int
110
110
return nil
111
111
}
112
112
113
- func downloadWithProgress (config DownloadConfig , fileSize int64 , progressCh chan <- int64 ) error {
113
+ func downloadWithProgress (config DownloadConfig , client * http. Client , fileSize int64 , progressCh chan <- int64 ) error {
114
114
log := GetLogger ("download-worker" )
115
- client := createHTTPClient (config .Timeout , config .KATimeout , config .ProxyURL )
115
+ // client := createHTTPClient(config.Timeout, config.KATimeout, config.ProxyURL)
116
116
log .Debug ().Str ("size" , formatBytes (uint64 (fileSize ))).Msg ("File size determined" )
117
117
job := DownloadJob {
118
118
Config : config ,
0 commit comments