From: Chocobozzz Date: Tue, 14 Jun 2016 18:14:17 +0000 (+0200) Subject: Remove useless use of async.each X-Git-Tag: v0.0.1-alpha~853 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=3c8ee69f8857c38d4f9047e8e2549063dfd922e3;hp=bf4c77f0f4bded073187a91d6c247071a3a75e5d;p=github%2FChocobozzz%2FPeerTube.git Remove useless use of async.each --- diff --git a/server/lib/requestsScheduler.js b/server/lib/requestsScheduler.js index 3c1df5d5c..78570209d 100644 --- a/server/lib/requestsScheduler.js +++ b/server/lib/requestsScheduler.js @@ -152,7 +152,7 @@ function makeRequests () { } // For each requests to make, we add it to the correct request type - async.each(requests, function (poolRequest, callbackEach) { + requests.forEach(function (poolRequest) { if (REQUEST_SCHEDULER_TYPE.indexOf(poolRequest.type) > -1) { const requestTypeToMake = requestsToMake[poolRequest.type] requestTypeToMake.requests.push(poolRequest.request) @@ -161,22 +161,20 @@ function makeRequests () { logger.error('Unkown request type.', { request_type: poolRequest.type }) return // abort } + }) - callbackEach() - }, function () { - for (let type of Object.keys(requestsToMake)) { - const requestTypeToMake = requestsToMake[type] - // If there are requests for this type - if (requestTypeToMake.requests.length !== 0) { - makeRequest(type, requestTypeToMake.requests, function (err) { - if (err) logger.error('Errors when sent ' + type + ' requests.', { error: err }) - - // We made the requests, so we can remove them from the scheduler - Requests.removeRequests(requestTypeToMake.ids) - }) - } + for (let type of Object.keys(requestsToMake)) { + const requestTypeToMake = requestsToMake[type] + // If there are requests for this type + if (requestTypeToMake.requests.length !== 0) { + makeRequest(type, requestTypeToMake.requests, function (err) { + if (err) logger.error('Errors when sent ' + type + ' requests.', { error: err }) + + // We made the requests, so we can remove them from the scheduler + Requests.removeRequests(requestTypeToMake.ids) + }) } - }) + } }) }