diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-07-18 17:17:52 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-07-18 17:17:52 +0200 |
commit | 1a42c9e2c0fb64cdbebd81b311736e752f591e0a (patch) | |
tree | e893324d730878257491428ffca634a92f1eea05 /server/models | |
parent | d56ec0d4129160a6e3b51ace3766bb325db1f101 (diff) | |
download | PeerTube-1a42c9e2c0fb64cdbebd81b311736e752f591e0a.tar.gz PeerTube-1a42c9e2c0fb64cdbebd81b311736e752f591e0a.tar.zst PeerTube-1a42c9e2c0fb64cdbebd81b311736e752f591e0a.zip |
Server: udpate async to 2.0.0
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/request.js | 12 | ||||
-rw-r--r-- | server/models/video.js | 11 |
2 files changed, 13 insertions, 10 deletions
diff --git a/server/models/request.js b/server/models/request.js index 248ab3303..4d521919a 100644 --- a/server/models/request.js +++ b/server/models/request.js | |||
@@ -1,8 +1,10 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const async = require('async') | 3 | const each = require('async/each') |
4 | const eachLimit = require('async/eachLimit') | ||
4 | const map = require('lodash/map') | 5 | const map = require('lodash/map') |
5 | const mongoose = require('mongoose') | 6 | const mongoose = require('mongoose') |
7 | const waterfall = require('async/waterfall') | ||
6 | 8 | ||
7 | const constants = require('../initializers/constants') | 9 | const constants = require('../initializers/constants') |
8 | const logger = require('../helpers/logger') | 10 | const logger = require('../helpers/logger') |
@@ -136,7 +138,7 @@ function makeRequests () { | |||
136 | const goodPods = [] | 138 | const goodPods = [] |
137 | const badPods = [] | 139 | const badPods = [] |
138 | 140 | ||
139 | async.eachLimit(Object.keys(requestsToMake), constants.REQUESTS_IN_PARALLEL, function (toPodId, callbackEach) { | 141 | eachLimit(Object.keys(requestsToMake), constants.REQUESTS_IN_PARALLEL, function (toPodId, callbackEach) { |
140 | const requestToMake = requestsToMake[toPodId] | 142 | const requestToMake = requestsToMake[toPodId] |
141 | 143 | ||
142 | // FIXME: mongodb request inside a loop :/ | 144 | // FIXME: mongodb request inside a loop :/ |
@@ -183,7 +185,7 @@ function makeRequests () { | |||
183 | 185 | ||
184 | // Remove pods with a score of 0 (too many requests where they were unreachable) | 186 | // Remove pods with a score of 0 (too many requests where they were unreachable) |
185 | function removeBadPods () { | 187 | function removeBadPods () { |
186 | async.waterfall([ | 188 | waterfall([ |
187 | function findBadPods (callback) { | 189 | function findBadPods (callback) { |
188 | Pod.listBadPods(function (err, pods) { | 190 | Pod.listBadPods(function (err, pods) { |
189 | if (err) { | 191 | if (err) { |
@@ -217,7 +219,7 @@ function removeBadPods () { | |||
217 | return callback(null) | 219 | return callback(null) |
218 | } | 220 | } |
219 | 221 | ||
220 | async.each(videosList, function (video, callbackEach) { | 222 | each(videosList, function (video, callbackEach) { |
221 | video.remove(callbackEach) | 223 | video.remove(callbackEach) |
222 | }, function (err) { | 224 | }, function (err) { |
223 | if (err) { | 225 | if (err) { |
@@ -237,7 +239,7 @@ function removeBadPods () { | |||
237 | return callback(null) | 239 | return callback(null) |
238 | } | 240 | } |
239 | 241 | ||
240 | async.each(pods, function (pod, callbackEach) { | 242 | each(pods, function (pod, callbackEach) { |
241 | pod.remove(callbackEach) | 243 | pod.remove(callbackEach) |
242 | }, function (err) { | 244 | }, function (err) { |
243 | if (err) return callback(err) | 245 | if (err) return callback(err) |
diff --git a/server/models/video.js b/server/models/video.js index 8054caa77..98f43a06d 100644 --- a/server/models/video.js +++ b/server/models/video.js | |||
@@ -1,9 +1,10 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const async = require('async') | ||
4 | const config = require('config') | 3 | const config = require('config') |
4 | const each = require('async/each') | ||
5 | const ffmpeg = require('fluent-ffmpeg') | 5 | const ffmpeg = require('fluent-ffmpeg') |
6 | const fs = require('fs') | 6 | const fs = require('fs') |
7 | const parallel = require('async/parallel') | ||
7 | const pathUtils = require('path') | 8 | const pathUtils = require('path') |
8 | const mongoose = require('mongoose') | 9 | const mongoose = require('mongoose') |
9 | 10 | ||
@@ -90,7 +91,7 @@ VideoSchema.pre('remove', function (next) { | |||
90 | ) | 91 | ) |
91 | } | 92 | } |
92 | 93 | ||
93 | async.parallel(tasks, next) | 94 | parallel(tasks, next) |
94 | }) | 95 | }) |
95 | 96 | ||
96 | VideoSchema.pre('save', function (next) { | 97 | VideoSchema.pre('save', function (next) { |
@@ -110,7 +111,7 @@ VideoSchema.pre('save', function (next) { | |||
110 | } | 111 | } |
111 | ) | 112 | ) |
112 | 113 | ||
113 | async.parallel(tasks, function (err, results) { | 114 | parallel(tasks, function (err, results) { |
114 | if (err) return next(err) | 115 | if (err) return next(err) |
115 | 116 | ||
116 | video.magnetUri = results[0].magnetURI | 117 | video.magnetUri = results[0].magnetURI |
@@ -234,7 +235,7 @@ function seedAllExisting (callback) { | |||
234 | listOwned.call(this, function (err, videos) { | 235 | listOwned.call(this, function (err, videos) { |
235 | if (err) return callback(err) | 236 | if (err) return callback(err) |
236 | 237 | ||
237 | async.each(videos, function (video, callbackEach) { | 238 | each(videos, function (video, callbackEach) { |
238 | const videoPath = pathUtils.join(uploadsDir, video.filename) | 239 | const videoPath = pathUtils.join(uploadsDir, video.filename) |
239 | seed(videoPath, callbackEach) | 240 | seed(videoPath, callbackEach) |
240 | }, callback) | 241 | }, callback) |
@@ -246,7 +247,7 @@ function seedAllExisting (callback) { | |||
246 | function findWithCount (query, start, count, sort, callback) { | 247 | function findWithCount (query, start, count, sort, callback) { |
247 | const self = this | 248 | const self = this |
248 | 249 | ||
249 | async.parallel([ | 250 | parallel([ |
250 | function (asyncCallback) { | 251 | function (asyncCallback) { |
251 | self.find(query).skip(start).limit(count).sort(sort).exec(asyncCallback) | 252 | self.find(query).skip(start).limit(count).sort(sort).exec(asyncCallback) |
252 | }, | 253 | }, |