diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-10-07 11:08:55 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-10-07 13:59:06 +0200 |
commit | bf94b6f0a1ac2cd5304f5cc7f85434120489cab8 (patch) | |
tree | 5cdf45935c8e574c3232b095b43ae17189603164 /server/models/video.js | |
parent | 82e624233f22eba0230383c7de8a9ed3b69791a6 (diff) | |
download | PeerTube-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.js | 7 |
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') | |||
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) { |