]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/peertube-crypto.js
Update standard -> 10
[github/Chocobozzz/PeerTube.git] / server / helpers / peertube-crypto.js
index ef6808d5ce1edf4dc54e89535babebe622dda8a2..55ae6fab3274a62e311b142944fe773d902ae5b7 100644 (file)
@@ -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)