Skip to content

Commit

Permalink
update on read Permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
mateenmohsin committed Jun 6, 2018
1 parent 9435b12 commit 9ce436d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions folder-analyzer/analyser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}
}

};
Expand Down

0 comments on commit 9ce436d

Please sign in to comment.