added readability check for fs.access

This commit is contained in:
Clément GOUIN
2019-06-20 10:50:48 +02:00
parent f9a2db38d2
commit dcb4e01447
+5 -5
View File
@@ -44,9 +44,9 @@ module.exports = (config) => {
}; };
const showError = (resPath, code, res) => { const showError = (resPath, code, res) => {
const errorPath = path.join(config['data_dir'],config['home']['error']); const errorPath = path.join(config['data_dir'], config['home']['error']);
fs.access(errorPath, (err) => { fs.access(errorPath, fs.constants.R_OK, (err) => {
if(err) if (err)
res.sendStatus(code); res.sendStatus(code);
else else
render(res, errorPath, {error: code, path: resPath}, code); render(res, errorPath, {error: code, path: resPath}, code);
@@ -55,8 +55,8 @@ module.exports = (config) => {
app.get('/', (req, res) => { app.get('/', (req, res) => {
const homePath = `${config['data_dir']}/${config['home']['index']}`; const homePath = `${config['data_dir']}/${config['home']['index']}`;
fs.access(homePath,(err)=>{ fs.access(homePath, fs.constants.R_OK, (err) => {
if(err) if (err)
showError(req.path, 404, res); showError(req.path, 404, res);
else else
render(res, homePath, {articles: articles}); render(res, homePath, {articles: articles});