From 9ce436deb48d03a6afdcfe41546752c6153da417 Mon Sep 17 00:00:00 2001 From: mateenmohsin Date: Wed, 6 Jun 2018 11:30:27 +0500 Subject: [PATCH] update on read Permission check --- folder-analyzer/analyser.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/folder-analyzer/analyser.js b/folder-analyzer/analyser.js index fb8725a..f7b23fa 100644 --- a/folder-analyzer/analyser.js +++ b/folder-analyzer/analyser.js @@ -7,6 +7,7 @@ const fs = require('fs'); let totalFiles = 0; let dir = 0; let dirSize = 0; +let checkDirCount = 0; const mbConst = 1048576; const results = { @@ -107,6 +108,7 @@ function analyzingDir(startPath){ try{ + checkDirCount++; const files = fs.readdirSync(startPath); //reading the files in that directory. let filename = null; let fileStatus = null; @@ -130,8 +132,15 @@ function analyzingDir(startPath){ } catch(error){ - console.log("Note: Please give the Read Permission to this directory structure,\nor try with the user who has Read Permission to this directory structure!"); - process.exit(); + + if(checkDirCount > 1){ + dir--; + console.log("\nPermission to this Directory Structure is denied : "+error.path); + } + else{ + console.log("Note: Please give the Read Permission to this directory structure,\nor try with the user who has Read Permission to this directory structure!"); + process.exit(); + } } };