aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/requestsScheduler.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-06-14 20:14:17 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-06-14 20:14:17 +0200
commit3c8ee69f8857c38d4f9047e8e2549063dfd922e3 (patch)
treea6762feeb4fc76af5f6802e60986deb47614fd7d /server/lib/requestsScheduler.js
parentbf4c77f0f4bded073187a91d6c247071a3a75e5d (diff)
downloadPeerTube-3c8ee69f8857c38d4f9047e8e2549063dfd922e3.tar.gz
PeerTube-3c8ee69f8857c38d4f9047e8e2549063dfd922e3.tar.zst
PeerTube-3c8ee69f8857c38d4f9047e8e2549063dfd922e3.zip
Remove useless use of async.each
Diffstat (limited to 'server/lib/requestsScheduler.js')
-rw-r--r--server/lib/requestsScheduler.js28
1 files changed, 13 insertions, 15 deletions
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 () {
152 } 152 }
153 153
154 // For each requests to make, we add it to the correct request type 154 // For each requests to make, we add it to the correct request type
155 async.each(requests, function (poolRequest, callbackEach) { 155 requests.forEach(function (poolRequest) {
156 if (REQUEST_SCHEDULER_TYPE.indexOf(poolRequest.type) > -1) { 156 if (REQUEST_SCHEDULER_TYPE.indexOf(poolRequest.type) > -1) {
157 const requestTypeToMake = requestsToMake[poolRequest.type] 157 const requestTypeToMake = requestsToMake[poolRequest.type]
158 requestTypeToMake.requests.push(poolRequest.request) 158 requestTypeToMake.requests.push(poolRequest.request)
@@ -161,22 +161,20 @@ function makeRequests () {
161 logger.error('Unkown request type.', { request_type: poolRequest.type }) 161 logger.error('Unkown request type.', { request_type: poolRequest.type })
162 return // abort 162 return // abort
163 } 163 }
164 })
164 165
165 callbackEach() 166 for (let type of Object.keys(requestsToMake)) {
166 }, function () { 167 const requestTypeToMake = requestsToMake[type]
167 for (let type of Object.keys(requestsToMake)) { 168 // If there are requests for this type
168 const requestTypeToMake = requestsToMake[type] 169 if (requestTypeToMake.requests.length !== 0) {
169 // If there are requests for this type 170 makeRequest(type, requestTypeToMake.requests, function (err) {
170 if (requestTypeToMake.requests.length !== 0) { 171 if (err) logger.error('Errors when sent ' + type + ' requests.', { error: err })
171 makeRequest(type, requestTypeToMake.requests, function (err) { 172
172 if (err) logger.error('Errors when sent ' + type + ' requests.', { error: err }) 173 // We made the requests, so we can remove them from the scheduler
173 174 Requests.removeRequests(requestTypeToMake.ids)
174 // We made the requests, so we can remove them from the scheduler 175 })
175 Requests.removeRequests(requestTypeToMake.ids)
176 })
177 }
178 } 176 }
179 }) 177 }
180 }) 178 })
181} 179}
182 180