"postinstall": "cd client && npm install"
},
"dependencies": {
- "async": "^1.2.1",
+ "async": "^2.0.0",
"bittorrent-tracker": "^8.0.0",
"body-parser": "^1.12.4",
"concurrently": "^2.0.0",
"morgan": "^1.5.3",
"multer": "^1.1.0",
"node-ipc": "^8.0.0",
- "node-sass": "^3.4.2",
"openssl-wrapper": "^0.3.4",
"password-generator": "^2.0.2",
"request": "^2.57.0",
'use strict'
-const async = require('async')
+const each = require('async/each')
const express = require('express')
const mongoose = require('mongoose')
+const waterfall = require('async/waterfall')
const logger = require('../../../helpers/logger')
const friends = require('../../../lib/friends')
function addPods (req, res, next) {
const informations = req.body
- async.waterfall([
+ waterfall([
function addPod (callback) {
const pod = new Pod(informations)
pod.save(function (err, podCreated) {
function removePods (req, res, next) {
const url = req.body.signature.url
- async.waterfall([
+ waterfall([
function loadPod (callback) {
Pod.loadByUrl(url, callback)
},
},
function removeTheRemoteVideos (videosList, callback) {
- async.each(videosList, function (video, callbackEach) {
+ each(videosList, function (video, callbackEach) {
video.remove(callbackEach)
}, callback)
}
'use strict'
-const async = require('async')
+const each = require('async/each')
+const eachSeries = require('async/eachSeries')
const express = require('express')
const mongoose = require('mongoose')
// We need to process in the same order to keep consistency
// TODO: optimization
- async.eachSeries(requests, function (request, callbackEach) {
+ eachSeries(requests, function (request, callbackEach) {
const videoData = request.data
if (request.type === 'add') {
logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podUrl: fromUrl })
}
- async.each(videosList, function (video, callbackEach) {
+ each(videosList, function (video, callbackEach) {
logger.debug('Removing remote video %s.', video.magnetUri)
video.remove(callbackEach)
'use strict'
-const async = require('async')
const config = require('config')
const express = require('express')
const mongoose = require('mongoose')
const multer = require('multer')
+const waterfall = require('async/waterfall')
const logger = require('../../../helpers/logger')
const friends = require('../../../lib/friends')
const videoFile = req.files.videofile[0]
const videoInfos = req.body
- async.waterfall([
+ waterfall([
function insertIntoDB (callback) {
const videoData = {
function removeVideo (req, res, next) {
const videoId = req.params.id
- async.waterfall([
+ waterfall([
function getVideo (callback) {
Video.load(videoId, callback)
},
'use strict'
-const async = require('async')
const config = require('config')
+const each = require('async/each')
const mkdirp = require('mkdirp')
const mongoose = require('mongoose')
const passwordGenerator = require('password-generator')
const path = require('path')
+const series = require('async/series')
const checker = require('./checker')
const logger = require('../helpers/logger')
}
function installApplication (callback) {
- async.series([
+ series([
function createDirectories (callbackAsync) {
createDirectoriesIfNotExist(callbackAsync)
},
function createDirectoriesIfNotExist (callback) {
const storages = config.get('storage')
- async.each(Object.keys(storages), function (key, callbackEach) {
+ each(Object.keys(storages), function (key, callbackEach) {
const dir = storages[key]
mkdirp(path.join(__dirname, '..', '..', dir), callbackEach)
}, callback)
'use strict'
-const async = require('async')
const config = require('config')
+const each = require('async/each')
+const eachLimit = require('async/eachLimit')
+const eachSeries = require('async/eachSeries')
const fs = require('fs')
const mongoose = require('mongoose')
const request = require('request')
+const waterfall = require('async/waterfall')
const constants = require('../initializers/constants')
const logger = require('../helpers/logger')
const urls = config.get('network.friends')
- async.eachSeries(urls, function (url, callbackEach) {
+ eachSeries(urls, function (url, callbackEach) {
computeForeignPodsList(url, podsScore, callbackEach)
}, function (err) {
if (err) return callback(err)
// Flush pool requests
Request.flush()
- async.waterfall([
+ waterfall([
function getPodsList (callbackAsync) {
return Pod.list(callbackAsync)
},
// Announce we quit them
// We don't care if the request fails
// The other pod will exclude us automatically after a while
- async.eachLimit(pods, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) {
+ eachLimit(pods, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) {
requestParams.toPod = pod
requests.makeSecureRequest(requestParams, callbackEach)
}, function (err) {
},
function removeTheRemoteVideos (videosList, callbackAsync) {
- async.each(videosList, function (video, callbackEach) {
+ each(videosList, function (video, callbackEach) {
video.remove(callbackEach)
}, callbackAsync)
}
// Flush pool requests
Request.forceSend()
- async.eachLimit(podsList, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) {
+ eachLimit(podsList, constants.REQUESTS_IN_PARALLEL, function (pod, callbackEach) {
const params = {
url: pod.url + '/api/' + constants.API_VERSION + '/pods/',
method: 'POST',
'use strict'
-const async = require('async')
+const each = require('async/each')
+const eachLimit = require('async/eachLimit')
const map = require('lodash/map')
const mongoose = require('mongoose')
+const waterfall = require('async/waterfall')
const constants = require('../initializers/constants')
const logger = require('../helpers/logger')
const goodPods = []
const badPods = []
- async.eachLimit(Object.keys(requestsToMake), constants.REQUESTS_IN_PARALLEL, function (toPodId, callbackEach) {
+ eachLimit(Object.keys(requestsToMake), constants.REQUESTS_IN_PARALLEL, function (toPodId, callbackEach) {
const requestToMake = requestsToMake[toPodId]
// FIXME: mongodb request inside a loop :/
// Remove pods with a score of 0 (too many requests where they were unreachable)
function removeBadPods () {
- async.waterfall([
+ waterfall([
function findBadPods (callback) {
Pod.listBadPods(function (err, pods) {
if (err) {
return callback(null)
}
- async.each(videosList, function (video, callbackEach) {
+ each(videosList, function (video, callbackEach) {
video.remove(callbackEach)
}, function (err) {
if (err) {
return callback(null)
}
- async.each(pods, function (pod, callbackEach) {
+ each(pods, function (pod, callbackEach) {
pod.remove(callbackEach)
}, function (err) {
if (err) return callback(err)
'use strict'
-const async = require('async')
const config = require('config')
+const each = require('async/each')
const ffmpeg = require('fluent-ffmpeg')
const fs = require('fs')
+const parallel = require('async/parallel')
const pathUtils = require('path')
const mongoose = require('mongoose')
)
}
- async.parallel(tasks, next)
+ parallel(tasks, next)
})
VideoSchema.pre('save', function (next) {
}
)
- async.parallel(tasks, function (err, results) {
+ parallel(tasks, function (err, results) {
if (err) return next(err)
video.magnetUri = results[0].magnetURI
listOwned.call(this, function (err, videos) {
if (err) return callback(err)
- async.each(videos, function (video, callbackEach) {
+ each(videos, function (video, callbackEach) {
const videoPath = pathUtils.join(uploadsDir, video.filename)
seed(videoPath, callbackEach)
}, callback)
function findWithCount (query, start, count, sort, callback) {
const self = this
- async.parallel([
+ parallel([
function (asyncCallback) {
self.find(query).skip(start).limit(count).sort(sort).exec(asyncCallback)
},
'use strict'
-const async = require('async')
const chai = require('chai')
const expect = chai.expect
const pathUtils = require('path')
const request = require('supertest')
+const series = require('async/series')
const utils = require('./utils')
before(function (done) {
this.timeout(20000)
- async.series([
+ series([
function (next) {
utils.flushTests(next)
},
'use strict'
-const async = require('async')
const chai = require('chai')
+const each = require('async/each')
const expect = chai.expect
+const series = require('async/series')
const utils = require('./utils')
utils.flushAndRunMultipleServers(6, function (serversRun, urlsRun) {
servers = serversRun
- async.each(servers, function (server, callbackEach) {
+ each(servers, function (server, callbackEach) {
utils.loginAndGetAccessToken(server, function (err, accessToken) {
if (err) return callbackEach(err)
it('Should make friends with two pod each in a different group', function (done) {
this.timeout(20000)
- async.series([
+ series([
// Pod 3 makes friend with the first one
function (next) {
makeFriends(3, next)
it('Should quit all friends', function (done) {
this.timeout(10000)
- async.series([
+ series([
function (next) {
quitFriends(1, next)
},
function (err) {
if (err) throw err
- async.each([ 1, 2, 3, 4, 5, 6 ], function (i, callback) {
+ each([ 1, 2, 3, 4, 5, 6 ], function (i, callback) {
getFriendsList(i, function (err, res) {
if (err) throw err
it('Should make friends with the pods 1, 2, 3', function (done) {
this.timeout(150000)
- async.series([
+ series([
// Pods 1, 2, 3 and 4 become friends
function (next) {
makeFriends(2, next)
},
// Check the pods 1, 2, 3 and 4 are friends
function (next) {
- async.each([ 1, 2, 3, 4 ], function (i, callback) {
+ each([ 1, 2, 3, 4 ], function (i, callback) {
getFriendsList(i, function (err, res) {
if (err) throw err
it('Should pod 1 quit friends', function (done) {
this.timeout(25000)
- async.series([
+ series([
// Upload a video on server 3 for aditionnal tests
function (next) {
uploadVideo(3, next)
'use strict'
-const async = require('async')
const chai = require('chai')
+const each = require('async/each')
const expect = chai.expect
+const series = require('async/series')
const utils = require('./utils')
utils.flushAndRunMultipleServers(3, function (serversRun, urlsRun) {
servers = serversRun
- async.each(servers, function (server, callbackEach) {
+ each(servers, function (server, callbackEach) {
utils.loginAndGetAccessToken(server, function (err, accessToken) {
if (err) return callbackEach(err)
})
it('Should not have friends', function (done) {
- async.each(servers, function (server, callback) {
+ each(servers, function (server, callback) {
utils.getFriendsList(server.url, function (err, res) {
if (err) throw err
it('Should make friends', function (done) {
this.timeout(10000)
- async.series([
+ series([
// The second pod make friend with the third
function (next) {
makeFriends(2, next)
// Now each pod should be friend with the other ones
function (err) {
if (err) throw err
- async.each(servers, function (server, callback) {
+ each(servers, function (server, callback) {
testMadeFriends(servers, server, callback)
}, done)
})
})
it('Should quit friends of pod 2', function (done) {
- async.series([
+ series([
// Pod 1 quit friends
function (next) {
const server = servers[1]
},
// Other pods shouldn't have pod 1 too
function (next) {
- async.each([ servers[0].url, servers[2].url ], function (url, callback) {
+ each([ servers[0].url, servers[2].url ], function (url, callback) {
utils.getFriendsList(url, function (err, res) {
if (err) throw err
it('Should allow pod 2 to make friend again', function (done) {
const server = servers[1]
utils.makeFriends(server.url, server.accessToken, function () {
- async.each(servers, function (server, callback) {
+ each(servers, function (server, callback) {
testMadeFriends(servers, server, callback)
}, done)
})
'use strict'
-const async = require('async')
const chai = require('chai')
+const each = require('async/each')
const expect = chai.expect
const pathUtils = require('path')
+const series = require('async/series')
const utils = require('./utils')
const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
before(function (done) {
this.timeout(30000)
- async.series([
+ series([
// Run servers
function (next) {
utils.flushAndRunMultipleServers(3, function (serversRun) {
},
// Get the access tokens
function (next) {
- async.each(servers, function (server, callbackEach) {
+ each(servers, function (server, callbackEach) {
utils.loginAndGetAccessToken(server, function (err, accessToken) {
if (err) return callbackEach(err)
})
it('Should not have videos for all pods', function (done) {
- async.each(servers, function (server, callback) {
+ each(servers, function (server, callback) {
utils.getVideosList(server.url, function (err, res) {
if (err) throw err
it('Should upload the video on pod 1 and propagate on each pod', function (done) {
this.timeout(15000)
- async.series([
+ series([
function (next) {
const name = 'my super name for pod 1'
const description = 'my super description for pod 1'
function (err) {
if (err) throw err
- async.each(servers, function (server, callback) {
+ each(servers, function (server, callback) {
let baseMagnet = null
utils.getVideosList(server.url, function (err, res) {
it('Should upload the video on pod 2 and propagate on each pod', function (done) {
this.timeout(15000)
- async.series([
+ series([
function (next) {
const name = 'my super name for pod 2'
const description = 'my super description for pod 2'
function (err) {
if (err) throw err
- async.each(servers, function (server, callback) {
+ each(servers, function (server, callback) {
let baseMagnet = null
utils.getVideosList(server.url, function (err, res) {
it('Should upload two videos on pod 3 and propagate on each pod', function (done) {
this.timeout(30000)
- async.series([
+ series([
function (next) {
const name = 'my super name for pod 3'
const description = 'my super description for pod 3'
let baseMagnet = null
// All pods should have this video
- async.each(servers, function (server, callback) {
+ each(servers, function (server, callback) {
utils.getVideosList(server.url, function (err, res) {
if (err) throw err
it('Should remove the file 3 and 3-2 by asking pod 3', function (done) {
this.timeout(15000)
- async.series([
+ series([
function (next) {
utils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[0], next)
},
})
it('Should have videos 1 and 3 on each pod', function (done) {
- async.each(servers, function (server, callback) {
+ each(servers, function (server, callback) {
utils.getVideosList(server.url, function (err, res) {
if (err) throw err
'use strict'
-const async = require('async')
const chai = require('chai')
+const each = require('async/each')
const expect = chai.expect
const fs = require('fs')
const keyBy = require('lodash/keyBy')
const pathUtils = require('path')
+const series = require('async/series')
const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
webtorrent.silent = true
before(function (done) {
this.timeout(20000)
- async.series([
+ series([
function (next) {
utils.flushTests(next)
},
'video_short.mp4', 'video_short.ogv', 'video_short.webm',
'video_short1.webm', 'video_short2.webm', 'video_short3.webm'
]
- async.each(videos, function (video, callbackEach) {
+ each(videos, function (video, callbackEach) {
const name = video + ' name'
const description = video + ' description'
const tags = [ 'tag1', 'tag2', 'tag3' ]
// For the next test
videosListBase = videos
- async.each(videos, function (video, callbackEach) {
+ each(videos, function (video, callbackEach) {
if (err) throw err
const videoName = video.name.replace(' name', '')
'use strict'
-const async = require('async')
const chai = require('chai')
const expect = chai.expect
const pathUtils = require('path')
+const series = require('async/series')
const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
webtorrent.silent = true
before(function (done) {
this.timeout(20000)
- async.series([
+ series([
function (next) {
utils.flushTests(next)
},
'use strict'
-const async = require('async')
-const program = require('commander')
+const each = require('each')
const isEqual = require('lodash/isEqual')
+const program = require('commander')
+const series = require('async/series')
process.env.NODE_ENV = 'test'
const constants = require('../../initializers/constants')
function runServers (numberOfPods, callback) {
let servers = null
- async.series([
+ series([
// Run servers
function (next) {
utils.flushAndRunMultipleServers(numberOfPods, function (serversRun) {
},
// Get the access tokens
function (next) {
- async.each(servers, function (server, callbackEach) {
+ each(servers, function (server, callbackEach) {
utils.loginAndGetAccessToken(server, function (err, accessToken) {
if (err) return callbackEach(err)
function checkIntegrity (servers, callback) {
const videos = []
- async.each(servers, function (server, callback) {
+ each(servers, function (server, callback) {
utils.getAllVideosListBy(server.url, function (err, res) {
if (err) throw err
const serverVideos = res.body.data