aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-25 16:03:33 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-26 09:11:38 +0200
commitf5028693a896a3076dd286ac0030e3d8f78f5ebf (patch)
tree09144ed6357e49ea575fb110247f933283ad235e /server/models
parenteb08047657e739bcd9e592d76307befa3998482b (diff)
downloadPeerTube-f5028693a896a3076dd286ac0030e3d8f78f5ebf.tar.gz
PeerTube-f5028693a896a3076dd286ac0030e3d8f78f5ebf.tar.zst
PeerTube-f5028693a896a3076dd286ac0030e3d8f78f5ebf.zip
Use async/await in lib and initializers
Diffstat (limited to 'server/models')
-rw-r--r--server/models/pod/pod.ts33
1 files changed, 17 insertions, 16 deletions
diff --git a/server/models/pod/pod.ts b/server/models/pod/pod.ts
index e4d7db48a..6619726af 100644
--- a/server/models/pod/pod.ts
+++ b/server/models/pod/pod.ts
@@ -247,20 +247,21 @@ updatePodsScore = function (goodPods: number[], badPods: number[]) {
247// --------------------------------------------------------------------------- 247// ---------------------------------------------------------------------------
248 248
249// Remove pods with a score of 0 (too many requests where they were unreachable) 249// Remove pods with a score of 0 (too many requests where they were unreachable)
250function removeBadPods () { 250async function removeBadPods () {
251 return listBadPods() 251 try {
252 .then(pods => { 252 const pods = await listBadPods()
253 const podsRemovePromises = pods.map(pod => pod.destroy()) 253
254 return Promise.all(podsRemovePromises).then(() => pods.length) 254 const podsRemovePromises = pods.map(pod => pod.destroy())
255 }) 255 await Promise.all(podsRemovePromises)
256 .then(numberOfPodsRemoved => { 256
257 if (numberOfPodsRemoved) { 257 const numberOfPodsRemoved = pods.length
258 logger.info('Removed %d pods.', numberOfPodsRemoved) 258
259 } else { 259 if (numberOfPodsRemoved) {
260 logger.info('No need to remove bad pods.') 260 logger.info('Removed %d pods.', numberOfPodsRemoved)
261 } 261 } else {
262 }) 262 logger.info('No need to remove bad pods.')
263 .catch(err => { 263 }
264 logger.error('Cannot remove bad pods.', err) 264 } catch (err) {
265 }) 265 logger.error('Cannot remove bad pods.', err)
266 }
266} 267}