aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-10-07 11:08:55 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-10-07 13:59:06 +0200
commitbf94b6f0a1ac2cd5304f5cc7f85434120489cab8 (patch)
tree5cdf45935c8e574c3232b095b43ae17189603164 /server/models/video.js
parent82e624233f22eba0230383c7de8a9ed3b69791a6 (diff)
downloadPeerTube-bf94b6f0a1ac2cd5304f5cc7f85434120489cab8.tar.gz
PeerTube-bf94b6f0a1ac2cd5304f5cc7f85434120489cab8.tar.zst
PeerTube-bf94b6f0a1ac2cd5304f5cc7f85434120489cab8.zip
Server: update to webseed implementation (tests, lint...)
Diffstat (limited to 'server/models/video.js')
-rw-r--r--server/models/video.js7
1 files changed, 2 insertions, 5 deletions
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')
19const http = config.get('webserver.https') === true ? 'https' : 'http' 19const http = config.get('webserver.https') === true ? 'https' : 'http'
20const host = config.get('webserver.host') 20const host = config.get('webserver.host')
21const port = config.get('webserver.port') 21const port = config.get('webserver.port')
22const uploadsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.uploads'))
23const thumbnailsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.thumbnails'))
24const torrentsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.torrents'))
25const webseedBaseUrl = http + '://' + host + ':' + port + constants.STATIC_PATHS.WEBSEED 22const 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
265function removeTorrent (video, callback) { 262function 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
269function createThumbnail (videoPath, callback) { 266function createThumbnail (videoPath, callback) {