diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/initializers/constants.js | 3 | ||||
-rw-r--r-- | server/models/video.js | 7 | ||||
-rw-r--r-- | server/tests/api/multiple-pods.js | 8 | ||||
-rw-r--r-- | server/tests/api/single-pod.js | 7 | ||||
-rw-r--r-- | server/tests/api/users.js | 3 |
5 files changed, 6 insertions, 22 deletions
diff --git a/server/initializers/constants.js b/server/initializers/constants.js index be2e3e943..75065fe72 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js | |||
@@ -42,7 +42,8 @@ const CONFIG = { | |||
42 | CERT_DIR: path.join(__dirname, '..', '..', config.get('storage.certs')), | 42 | CERT_DIR: path.join(__dirname, '..', '..', config.get('storage.certs')), |
43 | LOG_DIR: path.join(__dirname, '..', '..', config.get('storage.logs')), | 43 | LOG_DIR: path.join(__dirname, '..', '..', config.get('storage.logs')), |
44 | UPLOAD_DIR: path.join(__dirname, '..', '..', config.get('storage.uploads')), | 44 | UPLOAD_DIR: path.join(__dirname, '..', '..', config.get('storage.uploads')), |
45 | THUMBNAILS_DIR: path.join(__dirname, '..', '..', config.get('storage.thumbnails')) | 45 | THUMBNAILS_DIR: path.join(__dirname, '..', '..', config.get('storage.thumbnails')), |
46 | TORRENTS_DIR: path.join(__dirname, '..', '..', config.get('storage.torrents')) | ||
46 | }, | 47 | }, |
47 | WEBSERVER: { | 48 | WEBSERVER: { |
48 | SCHEME: config.get('webserver.https') === true ? 'https' : 'http', | 49 | SCHEME: config.get('webserver.https') === true ? 'https' : 'http', |
diff --git a/server/models/video.js b/server/models/video.js index 7d073cffa..9272bea6d 100644 --- a/server/models/video.js +++ b/server/models/video.js | |||
@@ -19,9 +19,6 @@ const utils = require('../helpers/utils') | |||
19 | const http = config.get('webserver.https') === true ? 'https' : 'http' | 19 | const http = config.get('webserver.https') === true ? 'https' : 'http' |
20 | const host = config.get('webserver.host') | 20 | const host = config.get('webserver.host') |
21 | const port = config.get('webserver.port') | 21 | const port = config.get('webserver.port') |
22 | const uploadsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.uploads')) | ||
23 | const thumbnailsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.thumbnails')) | ||
24 | const torrentsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.torrents')) | ||
25 | const webseedBaseUrl = http + '://' + host + ':' + port + constants.STATIC_PATHS.WEBSEED | 22 | const webseedBaseUrl = http + '://' + host + ':' + port + constants.STATIC_PATHS.WEBSEED |
26 | 23 | ||
27 | // --------------------------------------------------------------------------- | 24 | // --------------------------------------------------------------------------- |
@@ -112,7 +109,7 @@ VideoSchema.pre('save', function (next) { | |||
112 | createTorrent(videoPath, { announceList: [ [ 'ws://' + host + ':' + port + '/tracker/socket' ] ], urlList: [ webseedBaseUrl + video.filename ] }, function (err, torrent) { | 109 | createTorrent(videoPath, { announceList: [ [ 'ws://' + host + ':' + port + '/tracker/socket' ] ], urlList: [ webseedBaseUrl + video.filename ] }, function (err, torrent) { |
113 | if (err) return callback(err) | 110 | if (err) return callback(err) |
114 | 111 | ||
115 | fs.writeFile(torrentsDir + video.filename + '.torrent', torrent, function (err) { | 112 | fs.writeFile(constants.CONFIG.STORAGE.TORRENTS_DIR + video.filename + '.torrent', torrent, function (err) { |
116 | if (err) return callback(err) | 113 | if (err) return callback(err) |
117 | 114 | ||
118 | const parsedTorrent = parseTorrent(torrent) | 115 | const parsedTorrent = parseTorrent(torrent) |
@@ -263,7 +260,7 @@ function removeFile (video, callback) { | |||
263 | 260 | ||
264 | // Maybe the torrent is not seeded, but we catch the error to don't stop the removing process | 261 | // Maybe the torrent is not seeded, but we catch the error to don't stop the removing process |
265 | function removeTorrent (video, callback) { | 262 | function removeTorrent (video, callback) { |
266 | fs.unlink(torrentsDir + video.filename + '.torrent') | 263 | fs.unlink(constants.CONFIG.STORAGE.TORRENTS_DIR + video.filename + '.torrent', callback) |
267 | } | 264 | } |
268 | 265 | ||
269 | function createThumbnail (videoPath, callback) { | 266 | function createThumbnail (videoPath, callback) { |
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js index b86f88c22..87fab791c 100644 --- a/server/tests/api/multiple-pods.js +++ b/server/tests/api/multiple-pods.js | |||
@@ -3,16 +3,14 @@ | |||
3 | const chai = require('chai') | 3 | const chai = require('chai') |
4 | const each = require('async/each') | 4 | const each = require('async/each') |
5 | const expect = chai.expect | 5 | const expect = chai.expect |
6 | const pathUtils = require('path') | ||
7 | const series = require('async/series') | 6 | const series = require('async/series') |
7 | const webtorrent = new (require('webtorrent'))() | ||
8 | 8 | ||
9 | const loginUtils = require('../utils/login') | 9 | const loginUtils = require('../utils/login') |
10 | const miscsUtils = require('../utils/miscs') | 10 | const miscsUtils = require('../utils/miscs') |
11 | const podsUtils = require('../utils/pods') | 11 | const podsUtils = require('../utils/pods') |
12 | const serversUtils = require('../utils/servers') | 12 | const serversUtils = require('../utils/servers') |
13 | const videosUtils = require('../utils/videos') | 13 | const videosUtils = require('../utils/videos') |
14 | const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) | ||
15 | webtorrent.silent = true | ||
16 | 14 | ||
17 | describe('Test multiple pods', function () { | 15 | describe('Test multiple pods', function () { |
18 | let servers = [] | 16 | let servers = [] |
@@ -53,9 +51,6 @@ describe('Test multiple pods', function () { | |||
53 | function (next) { | 51 | function (next) { |
54 | const server = servers[0] | 52 | const server = servers[0] |
55 | podsUtils.makeFriends(server.url, server.accessToken, next) | 53 | podsUtils.makeFriends(server.url, server.accessToken, next) |
56 | }, | ||
57 | function (next) { | ||
58 | webtorrent.create({ host: 'client', port: '1' }, next) | ||
59 | } | 54 | } |
60 | ], done) | 55 | ], done) |
61 | }) | 56 | }) |
@@ -415,7 +410,6 @@ describe('Test multiple pods', function () { | |||
415 | servers.forEach(function (server) { | 410 | servers.forEach(function (server) { |
416 | process.kill(-server.app.pid) | 411 | process.kill(-server.app.pid) |
417 | }) | 412 | }) |
418 | process.kill(-webtorrent.app.pid) | ||
419 | 413 | ||
420 | // Keep the logs if the test failed | 414 | // Keep the logs if the test failed |
421 | if (this.ok) { | 415 | if (this.ok) { |
diff --git a/server/tests/api/single-pod.js b/server/tests/api/single-pod.js index bdaaee46c..623a1a6a3 100644 --- a/server/tests/api/single-pod.js +++ b/server/tests/api/single-pod.js | |||
@@ -7,13 +7,12 @@ const fs = require('fs') | |||
7 | const keyBy = require('lodash/keyBy') | 7 | const keyBy = require('lodash/keyBy') |
8 | const pathUtils = require('path') | 8 | const pathUtils = require('path') |
9 | const series = require('async/series') | 9 | const series = require('async/series') |
10 | const webtorrent = new (require('webtorrent'))() | ||
10 | 11 | ||
11 | const loginUtils = require('../utils/login') | 12 | const loginUtils = require('../utils/login') |
12 | const miscsUtils = require('../utils/miscs') | 13 | const miscsUtils = require('../utils/miscs') |
13 | const serversUtils = require('../utils/servers') | 14 | const serversUtils = require('../utils/servers') |
14 | const videosUtils = require('../utils/videos') | 15 | const videosUtils = require('../utils/videos') |
15 | const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) | ||
16 | webtorrent.silent = true | ||
17 | 16 | ||
18 | describe('Test a single pod', function () { | 17 | describe('Test a single pod', function () { |
19 | let server = null | 18 | let server = null |
@@ -39,9 +38,6 @@ describe('Test a single pod', function () { | |||
39 | server.accessToken = token | 38 | server.accessToken = token |
40 | next() | 39 | next() |
41 | }) | 40 | }) |
42 | }, | ||
43 | function (next) { | ||
44 | webtorrent.create({ host: 'client', port: '1' }, next) | ||
45 | } | 41 | } |
46 | ], done) | 42 | ], done) |
47 | }) | 43 | }) |
@@ -496,7 +492,6 @@ describe('Test a single pod', function () { | |||
496 | 492 | ||
497 | after(function (done) { | 493 | after(function (done) { |
498 | process.kill(-server.app.pid) | 494 | process.kill(-server.app.pid) |
499 | process.kill(-webtorrent.app.pid) | ||
500 | 495 | ||
501 | // Keep the logs if the test failed | 496 | // Keep the logs if the test failed |
502 | if (this.ok) { | 497 | if (this.ok) { |
diff --git a/server/tests/api/users.js b/server/tests/api/users.js index c6c892bf2..94267f104 100644 --- a/server/tests/api/users.js +++ b/server/tests/api/users.js | |||
@@ -2,7 +2,6 @@ | |||
2 | 2 | ||
3 | const chai = require('chai') | 3 | const chai = require('chai') |
4 | const expect = chai.expect | 4 | const expect = chai.expect |
5 | const pathUtils = require('path') | ||
6 | const series = require('async/series') | 5 | const series = require('async/series') |
7 | 6 | ||
8 | const loginUtils = require('../utils/login') | 7 | const loginUtils = require('../utils/login') |
@@ -10,8 +9,6 @@ const podsUtils = require('../utils/pods') | |||
10 | const serversUtils = require('../utils/servers') | 9 | const serversUtils = require('../utils/servers') |
11 | const usersUtils = require('../utils/users') | 10 | const usersUtils = require('../utils/users') |
12 | const videosUtils = require('../utils/videos') | 11 | const videosUtils = require('../utils/videos') |
13 | const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) | ||
14 | webtorrent.silent = true | ||
15 | 12 | ||
16 | describe('Test users', function () { | 13 | describe('Test users', function () { |
17 | let server = null | 14 | let server = null |