Reassign loop index to another variable
This commit is contained in:
@@ -123,12 +123,12 @@ func MainApp(configPath string) {
|
||||
)
|
||||
|
||||
//// pprof
|
||||
workerPool.Submit(func() {
|
||||
if err := netHttp.ListenAndServe(":6060", nil); err != nil && err != netHttp.ErrServerClosed {
|
||||
zurglog.Errorf("Failed to start pprof: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
})
|
||||
// workerPool.Submit(func() {
|
||||
// if err := netHttp.ListenAndServe(":6060", nil); err != nil && err != netHttp.ErrServerClosed {
|
||||
// zurglog.Errorf("Failed to start pprof: %v", err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
// })
|
||||
|
||||
addr := fmt.Sprintf("%s:%s", config.GetHost(), config.GetPort())
|
||||
zurglog.Infof("Starting server on %s", addr)
|
||||
|
||||
@@ -185,12 +185,13 @@ func (rd *RealDebrid) GetTorrents(onlyOne bool) ([]Torrent, int, error) {
|
||||
for {
|
||||
allResults := make(chan getTorrentsResult, maxParallelThreads) // Channel to collect results from goroutines
|
||||
for i := 0; i < maxParallelThreads; i++ { // Launch GET_PARALLEL concurrent fetches
|
||||
idx := i
|
||||
rd.workerPool.Submit(func() {
|
||||
if page > maxPages {
|
||||
allResults <- getTorrentsResult{nil, nil, 0}
|
||||
return
|
||||
}
|
||||
allResults <- rd.getPageOfTorrents(page+i, 250)
|
||||
allResults <- rd.getPageOfTorrents(page+idx, 250)
|
||||
})
|
||||
}
|
||||
// Collect results from all goroutines
|
||||
@@ -382,13 +383,14 @@ func (rd *RealDebrid) GetDownloads() []Download {
|
||||
allResults := make(chan []Download, maxParallelThreads) // Channel to collect results from goroutines
|
||||
errChan := make(chan error, maxParallelThreads) // Channel to collect errors from goroutines
|
||||
for i := 0; i < maxParallelThreads; i++ { // Launch GET_PARALLEL concurrent fetches
|
||||
idx := i
|
||||
rd.workerPool.Submit(func() {
|
||||
if page+i > maxPages {
|
||||
if page+idx > maxPages {
|
||||
allResults <- nil
|
||||
errChan <- nil
|
||||
return
|
||||
}
|
||||
result, _, err := rd.fetchPageOfDownloads(page+i, limit)
|
||||
result, _, err := rd.fetchPageOfDownloads(page+idx, limit)
|
||||
if err != nil {
|
||||
allResults <- nil
|
||||
errChan <- err
|
||||
|
||||
Reference in New Issue
Block a user