@@ -32,12 +32,13 @@ import (
3232type EngineManager struct {
3333 DB * gorm.DB
3434 //SyncLimiter *SmartLimiter // 专门用于同步列表
35- DownLimiter * SmartLimiter // 专门用于下载文件
36- Config * model.Config
37- WorkerPool * pond.Pool
38- Client * resty.Client
39- JWTToken string
40- ApiUrl string
35+ DownLimiter * SmartLimiter // 专门用于下载文件
36+ Config * model.Config
37+ WorkerPool * pond.Pool
38+ DownloadPool * pond.Pool
39+ Client * resty.Client
40+ JWTToken string
41+ ApiUrl string
4142 //批量通道 在元数据初始化的时候
4243 MetadataWorkBatchChan chan []model.MetadataWork
4344 //标记是否开启 条件db中有数据了
@@ -79,6 +80,7 @@ func NewEngineManager() *EngineManager {
7980 //并发
8081 workers := config .Downloader .MaxWorkers
8182 pool := pond .NewPool (workers )
83+ downloadPool := pond .NewPool (workers )
8284 //2个并发刚好
8385 syncPool := pond .NewPool (2 )
8486
@@ -101,11 +103,12 @@ func NewEngineManager() *EngineManager {
101103 // 下载限流器:较慢,因为下载是大动作 2s 一个
102104 DownLimiter : NewSmartLimiter (0.5 , 1 , 200 , 400 ),
103105 //配置
104- Config : config ,
105- WorkerPool : & pool ,
106- Client : client ,
107- JWTToken : "" ,
108- ApiUrl : apiUrl ,
106+ Config : config ,
107+ WorkerPool : & pool ,
108+ DownloadPool : & downloadPool ,
109+ Client : client ,
110+ JWTToken : "" ,
111+ ApiUrl : apiUrl ,
109112 //批量通道 在元数据初始化的时候 队列2也刚好 不会触发429
110113 MetadataWorkBatchChan : make (chan []model.MetadataWork , 50 ),
111114 //后续增量使用的通道
@@ -276,7 +279,7 @@ func (m *EngineManager) DownloadOne(id string, storeBaseDir string) error {
276279 //过滤掉不需要的格式
277280 needDownloadUrls = m .filterTargetAudioFormate (needDownloadUrls )
278281 //并行下载
279- pool := * m .WorkerPool
282+ pool := * m .DownloadPool
280283 group := pool .NewGroup ()
281284 for _ , url := range needDownloadUrls {
282285 //log.Println("Download file:", url[2])
0 commit comments