aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/initializers/constants.js1
-rw-r--r--server/models/video.js17
2 files changed, 11 insertions, 7 deletions
diff --git a/server/initializers/constants.js b/server/initializers/constants.js
index 09c4f755e..fb1cbc5f3 100644
--- a/server/initializers/constants.js
+++ b/server/initializers/constants.js
@@ -44,6 +44,7 @@ const CONFIG = {
44 }, 44 },
45 WEBSERVER: { 45 WEBSERVER: {
46 SCHEME: config.get('webserver.https') === true ? 'https' : 'http', 46 SCHEME: config.get('webserver.https') === true ? 'https' : 'http',
47 WS: config.get('webserver.https') === true ? 'wss' : 'ws',
47 HOST: config.get('webserver.host'), 48 HOST: config.get('webserver.host'),
48 PORT: config.get('webserver.port') 49 PORT: config.get('webserver.port')
49 } 50 }
diff --git a/server/models/video.js b/server/models/video.js
index 9272bea6d..4b941a40c 100644
--- a/server/models/video.js
+++ b/server/models/video.js
@@ -1,6 +1,5 @@
1'use strict' 1'use strict'
2 2
3const config = require('config')
4const createTorrent = require('create-torrent') 3const createTorrent = require('create-torrent')
5const ffmpeg = require('fluent-ffmpeg') 4const ffmpeg = require('fluent-ffmpeg')
6const fs = require('fs') 5const fs = require('fs')
@@ -16,11 +15,6 @@ const logger = require('../helpers/logger')
16const modelUtils = require('./utils') 15const modelUtils = require('./utils')
17const utils = require('../helpers/utils') 16const utils = require('../helpers/utils')
18 17
19const http = config.get('webserver.https') === true ? 'https' : 'http'
20const host = config.get('webserver.host')
21const port = config.get('webserver.port')
22const webseedBaseUrl = http + '://' + host + ':' + port + constants.STATIC_PATHS.WEBSEED
23
24// --------------------------------------------------------------------------- 18// ---------------------------------------------------------------------------
25 19
26// TODO: add indexes on searchable columns 20// TODO: add indexes on searchable columns
@@ -106,7 +100,16 @@ VideoSchema.pre('save', function (next) {
106 tasks.push( 100 tasks.push(
107 // TODO: refractoring 101 // TODO: refractoring
108 function (callback) { 102 function (callback) {
109 createTorrent(videoPath, { announceList: [ [ 'ws://' + host + ':' + port + '/tracker/socket' ] ], urlList: [ webseedBaseUrl + video.filename ] }, function (err, torrent) { 103 const options = {
104 announceList: [
105 [ constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOST + ':' + constants.CONFIG.WEBSERVER.PORT + '/tracker/socket' ]
106 ],
107 urlList: [
108 constants.CONFIG.WEBSERVER.URL + constants.STATIC_PATHS.WEBSEED + video.filename
109 ]
110 }
111
112 createTorrent(videoPath, options, function (err, torrent) {
110 if (err) return callback(err) 113 if (err) return callback(err)
111 114
112 fs.writeFile(constants.CONFIG.STORAGE.TORRENTS_DIR + video.filename + '.torrent', torrent, function (err) { 115 fs.writeFile(constants.CONFIG.STORAGE.TORRENTS_DIR + video.filename + '.torrent', torrent, function (err) {