VideosDB.findById(id, function (err, video) {
if (err || !video) {
+ if (!err) err = new Error('Cannot find this video.')
logger.error('Cannot find this video.', { error: err })
return callback(err)
}
var logger = require('./logger')
- var host
- var port
-
- try {
- host = config.get('webserver.host')
- port = config.get('webserver.port')
- } catch (e) {
- host = 'client'
- port = 1
- }
+ var host = config.get('webserver.host')
+ var port = config.get('webserver.port')
var nodeKey = 'webtorrentnode' + port
var processKey = 'webtorrent' + port
// Useful to kill it
webtorrentnode.app = null
- webtorrentnode.create = function (callback) {
+ webtorrentnode.create = function (options, callback) {
+ if (typeof options === 'function') {
+ callback = options
+ options = {}
+ }
+
+ // Override options
+ if (options.host) host = options.host
+ if (options.port) {
+ port = options.port
+ nodeKey = 'webtorrentnode' + port
+ processKey = 'webtorrent' + port
+ ipc.config.id = nodeKey
+ }
+
ipc.serve(function () {
if (!webtorrentnode.silent) logger.info('IPC server ready.')
.end(function (err, res) {
if (err) throw err
- webtorrent.create(function () {
+ webtorrent.create({ host: 'client', port: '1' }, function () {
done()
})
})
describe('Should seed the uploaded video', function () {
it('Should add the file 1 by asking pod 3', function (done) {
// Yes, this could be long
- this.timeout(60000)
+ this.timeout(200000)
getVideosList(urls[2], function (err, res) {
if (err) throw err
it('Should add the file 2 by asking pod 1', function (done) {
// Yes, this could be long
- this.timeout(60000)
+ this.timeout(200000)
getVideosList(urls[0], function (err, res) {
if (err) throw err
var video = res.body[1]
- video_id = video._id
-
webtorrent.add(video.magnetUri, function (torrent) {
expect(torrent.files).to.exist
expect(torrent.files.length).to.equal(1)
it('Should add the file 3 by asking pod 2', function (done) {
// Yes, this could be long
- this.timeout(60000)
+ this.timeout(200000)
getVideosList(urls[1], function (err, res) {
if (err) throw err
var video = res.body[2]
+ video_id = res.body[1]._id
webtorrent.add(video.magnetUri, function (torrent) {
expect(torrent.files).to.exist