aboutsummaryrefslogtreecommitdiffhomepage
path: root/helpers
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-02-05 19:02:05 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-02-05 19:02:05 +0100
commit8425cb894d4867d26fd5f7fae7862b0669f3c717 (patch)
tree5e2f00a8219e198f2dd074ca13f3ae681174228f /helpers
parentdac0a5319ab1c52a0958647b1593f85339b77e29 (diff)
downloadPeerTube-8425cb894d4867d26fd5f7fae7862b0669f3c717.tar.gz
PeerTube-8425cb894d4867d26fd5f7fae7862b0669f3c717.tar.zst
PeerTube-8425cb894d4867d26fd5f7fae7862b0669f3c717.zip
Error handling mini refractoring
Diffstat (limited to 'helpers')
-rw-r--r--helpers/peertubeCrypto.js12
-rw-r--r--helpers/utils.js2
2 files changed, 5 insertions, 9 deletions
diff --git a/helpers/peertubeCrypto.js b/helpers/peertubeCrypto.js
index 3e757659b..36271dba9 100644
--- a/helpers/peertubeCrypto.js
+++ b/helpers/peertubeCrypto.js
@@ -101,7 +101,7 @@
101 logger.info('Generating a RSA key...') 101 logger.info('Generating a RSA key...')
102 openssl.exec('genrsa', { 'out': certDir + 'peertube.key.pem', '2048': false }, function (err) { 102 openssl.exec('genrsa', { 'out': certDir + 'peertube.key.pem', '2048': false }, function (err) {
103 if (err) { 103 if (err) {
104 logger.error('Cannot create private key on this pod.', { error: err }) 104 logger.error('Cannot create private key on this pod.')
105 return callback(err) 105 return callback(err)
106 } 106 }
107 logger.info('RSA key generated.') 107 logger.info('RSA key generated.')
@@ -109,7 +109,7 @@
109 logger.info('Manage public key...') 109 logger.info('Manage public key...')
110 openssl.exec('rsa', { 'in': certDir + 'peertube.key.pem', 'pubout': true, 'out': certDir + 'peertube.pub' }, function (err) { 110 openssl.exec('rsa', { 'in': certDir + 'peertube.key.pem', 'pubout': true, 'out': certDir + 'peertube.pub' }, function (err) {
111 if (err) { 111 if (err) {
112 logger.error('Cannot create public key on this pod .', { error: err }) 112 logger.error('Cannot create public key on this pod.')
113 return callback(err) 113 return callback(err)
114 } 114 }
115 115
@@ -122,9 +122,7 @@
122 122
123 function generatePassword (callback) { 123 function generatePassword (callback) {
124 crypto.randomBytes(32, function (err, buf) { 124 crypto.randomBytes(32, function (err, buf) {
125 if (err) { 125 if (err) return callback(err)
126 return callback(err)
127 }
128 126
129 callback(null, buf.toString('utf8')) 127 callback(null, buf.toString('utf8'))
130 }) 128 })
@@ -139,9 +137,7 @@
139 137
140 function symetricEncrypt (text, callback) { 138 function symetricEncrypt (text, callback) {
141 generatePassword(function (err, password) { 139 generatePassword(function (err, password) {
142 if (err) { 140 if (err) return callback(err)
143 return callback(err)
144 }
145 141
146 var cipher = crypto.createCipher(algorithm, password) 142 var cipher = crypto.createCipher(algorithm, password)
147 var crypted = cipher.update(text, 'utf8', 'hex') 143 var crypted = cipher.update(text, 'utf8', 'hex')
diff --git a/helpers/utils.js b/helpers/utils.js
index bd0557977..92684ea81 100644
--- a/helpers/utils.js
+++ b/helpers/utils.js
@@ -8,7 +8,7 @@
8 } 8 }
9 9
10 function cleanForExit (webtorrent_process) { 10 function cleanForExit (webtorrent_process) {
11 logger.info('Gracefully exiting') 11 logger.info('Gracefully exiting.')
12 process.kill(-webtorrent_process.pid) 12 process.kill(-webtorrent_process.pid)
13 } 13 }
14 14