From 0dd079da272df8d532f0086d7c91597b43e7a143 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 16 Apr 2017 14:25:37 +0200 Subject: Update standard -> 10 --- server/helpers/peertube-crypto.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/peertube-crypto.js b/server/helpers/peertube-crypto.js index ef6808d5c..55ae6fab3 100644 --- a/server/helpers/peertube-crypto.js +++ b/server/helpers/peertube-crypto.js @@ -74,7 +74,9 @@ function comparePassword (plainPassword, hashPassword, callback) { } function createCertsIfNotExist (callback) { - certsExist(function (exist) { + certsExist(function (err, exist) { + if (err) return callback(err) + if (exist === true) { return callback(null) } @@ -113,13 +115,17 @@ module.exports = peertubeCrypto function certsExist (callback) { const certPath = pathUtils.join(constants.CONFIG.STORAGE.CERT_DIR, constants.PRIVATE_CERT_NAME) - fs.exists(certPath, function (exists) { - return callback(exists) + fs.access(certPath, function (err) { + // If there is an error the certificates do not exist + const exists = !err + return callback(null, exists) }) } function createCerts (callback) { - certsExist(function (exist) { + certsExist(function (err, exist) { + if (err) return callback(err) + if (exist === true) { const string = 'Certs already exist.' logger.warning(string) -- cgit v1.2.3