From 0dd079da272df8d532f0086d7c91597b43e7a143 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 16 Apr 2017 14:25:37 +0200 Subject: Update standard -> 10 --- client/config/webpack.common.js | 1 - client/package.json | 2 +- package.json | 4 ++-- server/helpers/peertube-crypto.js | 14 ++++++++++---- server/lib/base-request-scheduler.js | 8 ++++---- server/tests/real-world/real-world.js | 6 ++++-- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/client/config/webpack.common.js b/client/config/webpack.common.js index 86cbf84d7..35ea8ed28 100644 --- a/client/config/webpack.common.js +++ b/client/config/webpack.common.js @@ -6,7 +6,6 @@ const helpers = require('./helpers') const AssetsPlugin = require('assets-webpack-plugin') const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin -const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin') const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin') const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin') const CopyWebpackPlugin = require('copy-webpack-plugin') diff --git a/client/package.json b/client/package.json index 00eb0e272..3e68007de 100644 --- a/client/package.json +++ b/client/package.json @@ -90,7 +90,7 @@ "devDependencies": { "add-asset-html-webpack-plugin": "^1.0.2", "codelyzer": "^2.0.0", - "standard": "^9.0.0", + "standard": "^10.0.0", "webpack-bundle-analyzer": "^2.2.1", "webpack-dll-bundles-plugin": "^1.0.0-beta.5" } diff --git a/package.json b/package.json index c4c56ebdd..281d169c6 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "password-generator": "^2.0.2", "pg": "^6.1.0", "pg-hstore": "^2.3.2", - "request": "^2.57.0", + "request": "^2.81.0", "request-replay": "^1.0.2", "rimraf": "^2.5.4", "safe-buffer": "^5.0.1", @@ -77,7 +77,7 @@ "chai": "^3.3.0", "commander": "^2.9.0", "mocha": "^3.0.1", - "standard": "^9.0.0", + "standard": "^10.0.0", "supertest": "^3.0.0", "webtorrent": "^0.98.0" }, 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) diff --git a/server/lib/base-request-scheduler.js b/server/lib/base-request-scheduler.js index 4709c7960..7378971c8 100644 --- a/server/lib/base-request-scheduler.js +++ b/server/lib/base-request-scheduler.js @@ -66,10 +66,10 @@ module.exports = class BaseRequestScheduler { err = err ? err.message : 'Status code not 20x : ' + res.statusCode logger.error('Error sending secure request to %s pod.', toPod.host, { error: err }) - return callback(false) + return callback(err) } - return callback(true) + return callback(null) }) } @@ -99,8 +99,8 @@ module.exports = class BaseRequestScheduler { const requestToMake = requestsToMakeGrouped[hashKey] const toPod = requestToMake.toPod - this.makeRequest(toPod, requestToMake.endpoint, requestToMake.datas, (success) => { - if (success === false) { + this.makeRequest(toPod, requestToMake.endpoint, requestToMake.datas, (err) => { + if (err) { badPods.push(requestToMake.toPod.id) return callbackEach() } diff --git a/server/tests/real-world/real-world.js b/server/tests/real-world/real-world.js index 21f0732d0..3ac13f053 100644 --- a/server/tests/real-world/real-world.js +++ b/server/tests/real-world/real-world.js @@ -102,7 +102,9 @@ runServers(numberOfPods, function (err, servers) { checking = true const waitingInterval = setInterval(function () { - isThereAwaitingRequests(servers, function (res) { + isThereAwaitingRequests(servers, function (err, res) { + if (err) throw err + if (res === true) { console.log('A server has awaiting requests, waiting...') return @@ -360,6 +362,6 @@ function isThereAwaitingRequests (servers, callback) { }, function (err) { if (err) throw err - return callback(noRequests === false) + return callback(null, noRequests === false) }) } -- cgit v1.2.3