X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fpeertube-crypto.js;h=55ae6fab3274a62e311b142944fe773d902ae5b7;hb=0dd079da272df8d532f0086d7c91597b43e7a143;hp=ef6808d5ce1edf4dc54e89535babebe622dda8a2;hpb=3758da9489b636997a3a4fad7fc1a6081737bbe0;p=github%2FChocobozzz%2FPeerTube.git 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)