aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/webtorrent.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-11 21:19:34 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-13 14:23:11 +0200
commitbc503c2a62dcf9aed6b8d90b68f0f27a7755ac01 (patch)
treea1fe1ad88afd29ee4d7cb05c480649d5a9c6f9a0 /server/lib/webtorrent.js
parent881a5e68b64e4acd43408852bbdc914643d8fac6 (diff)
downloadPeerTube-bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01.tar.gz
PeerTube-bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01.tar.zst
PeerTube-bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01.zip
Update to standard 7. Goodbye snake_case, I used to love you
Diffstat (limited to 'server/lib/webtorrent.js')
-rw-r--r--server/lib/webtorrent.js34
1 files changed, 17 insertions, 17 deletions
diff --git a/server/lib/webtorrent.js b/server/lib/webtorrent.js
index 656f8c7a8..fe2ee357f 100644
--- a/server/lib/webtorrent.js
+++ b/server/lib/webtorrent.js
@@ -7,7 +7,7 @@ const spawn = require('electron-spawn')
7 7
8const logger = require('../helpers/logger') 8const logger = require('../helpers/logger')
9 9
10const electron_debug = config.get('electron.debug') 10const electronDebug = config.get('electron.debug')
11let host = config.get('webserver.host') 11let host = config.get('webserver.host')
12let port = config.get('webserver.port') 12let port = config.get('webserver.port')
13let nodeKey = 'webtorrentnode' + port 13let nodeKey = 'webtorrentnode' + port
@@ -43,13 +43,13 @@ function create (options, callback) {
43 if (!webtorrent.silent) logger.info('IPC server ready.') 43 if (!webtorrent.silent) logger.info('IPC server ready.')
44 44
45 // Run a timeout of 30s after which we exit the process 45 // Run a timeout of 30s after which we exit the process
46 const timeout_webtorrent_process = setTimeout(function () { 46 const timeoutWebtorrentProcess = setTimeout(function () {
47 throw new Error('Timeout : cannot run the webtorrent process. Please ensure you have electron-prebuilt npm package installed with xvfb-run.') 47 throw new Error('Timeout : cannot run the webtorrent process. Please ensure you have electron-prebuilt npm package installed with xvfb-run.')
48 }, 30000) 48 }, 30000)
49 49
50 ipc.server.on(processKey + '.ready', function () { 50 ipc.server.on(processKey + '.ready', function () {
51 if (!webtorrent.silent) logger.info('Webtorrent process ready.') 51 if (!webtorrent.silent) logger.info('Webtorrent process ready.')
52 clearTimeout(timeout_webtorrent_process) 52 clearTimeout(timeoutWebtorrentProcess)
53 callback() 53 callback()
54 }) 54 })
55 55
@@ -57,19 +57,19 @@ function create (options, callback) {
57 throw new Error('Received exception error from webtorrent process : ' + data.exception) 57 throw new Error('Received exception error from webtorrent process : ' + data.exception)
58 }) 58 })
59 59
60 const webtorrent_process = spawn(pathUtils.join(__dirname, 'webtorrentProcess.js'), host, port, { detached: true }) 60 const webtorrentProcess = spawn(pathUtils.join(__dirname, 'webtorrentProcess.js'), host, port, { detached: true })
61 61
62 if (electron_debug === true) { 62 if (electronDebug === true) {
63 webtorrent_process.stderr.on('data', function (data) { 63 webtorrentProcess.stderr.on('data', function (data) {
64 logger.debug('Webtorrent process stderr: ', data.toString()) 64 logger.debug('Webtorrent process stderr: ', data.toString())
65 }) 65 })
66 66
67 webtorrent_process.stdout.on('data', function (data) { 67 webtorrentProcess.stdout.on('data', function (data) {
68 logger.debug('Webtorrent process:', data.toString()) 68 logger.debug('Webtorrent process:', data.toString())
69 }) 69 })
70 } 70 }
71 71
72 webtorrent.app = webtorrent_process 72 webtorrent.app = webtorrentProcess
73 }) 73 })
74 74
75 ipc.server.start() 75 ipc.server.start()
@@ -88,8 +88,8 @@ function seed (path, callback) {
88 if (!webtorrent.silent) logger.debug('Node wants to seed %s.', data._id) 88 if (!webtorrent.silent) logger.debug('Node wants to seed %s.', data._id)
89 89
90 // Finish signal 90 // Finish signal
91 const event_key = nodeKey + '.seedDone.' + data._id 91 const eventKey = nodeKey + '.seedDone.' + data._id
92 ipc.server.on(event_key, function listener (received) { 92 ipc.server.on(eventKey, function listener (received) {
93 if (!webtorrent.silent) logger.debug('Process seeded torrent %s.', received.magnetUri) 93 if (!webtorrent.silent) logger.debug('Process seeded torrent %s.', received.magnetUri)
94 94
95 // This is a fake object, we just use the magnetUri in this project 95 // This is a fake object, we just use the magnetUri in this project
@@ -97,7 +97,7 @@ function seed (path, callback) {
97 magnetURI: received.magnetUri 97 magnetURI: received.magnetUri
98 } 98 }
99 99
100 ipc.server.off(event_key) 100 ipc.server.off(eventKey)
101 callback(torrent) 101 callback(torrent)
102 }) 102 })
103 103
@@ -115,8 +115,8 @@ function add (magnetUri, callback) {
115 if (!webtorrent.silent) logger.debug('Node wants to add ' + data._id) 115 if (!webtorrent.silent) logger.debug('Node wants to add ' + data._id)
116 116
117 // Finish signal 117 // Finish signal
118 const event_key = nodeKey + '.addDone.' + data._id 118 const eventKey = nodeKey + '.addDone.' + data._id
119 ipc.server.on(event_key, function (received) { 119 ipc.server.on(eventKey, function (received) {
120 if (!webtorrent.silent) logger.debug('Process added torrent.') 120 if (!webtorrent.silent) logger.debug('Process added torrent.')
121 121
122 // This is a fake object, we just use the magnetUri in this project 122 // This is a fake object, we just use the magnetUri in this project
@@ -124,7 +124,7 @@ function add (magnetUri, callback) {
124 files: received.files 124 files: received.files
125 } 125 }
126 126
127 ipc.server.off(event_key) 127 ipc.server.off(eventKey)
128 callback(torrent) 128 callback(torrent)
129 }) 129 })
130 130
@@ -142,14 +142,14 @@ function remove (magnetUri, callback) {
142 if (!webtorrent.silent) logger.debug('Node wants to stop seeding %s.', data._id) 142 if (!webtorrent.silent) logger.debug('Node wants to stop seeding %s.', data._id)
143 143
144 // Finish signal 144 // Finish signal
145 const event_key = nodeKey + '.removeDone.' + data._id 145 const eventKey = nodeKey + '.removeDone.' + data._id
146 ipc.server.on(event_key, function (received) { 146 ipc.server.on(eventKey, function (received) {
147 if (!webtorrent.silent) logger.debug('Process removed torrent %s.', data._id) 147 if (!webtorrent.silent) logger.debug('Process removed torrent %s.', data._id)
148 148
149 let err = null 149 let err = null
150 if (received.err) err = received.err 150 if (received.err) err = received.err
151 151
152 ipc.server.off(event_key) 152 ipc.server.off(eventKey)
153 callback(err) 153 callback(err)
154 }) 154 })
155 155