added more logic

This commit is contained in:
Andrew Koung 2019-03-19 21:55:29 -04:00
parent 58a3a30a6b
commit 0d292068c4
1 changed files with 12 additions and 4 deletions

View File

@ -224,17 +224,25 @@ function FileSystem(options, callback) {
const interval = options.interval || 5007; const interval = options.interval || 5007;
listener = listener || nop; listener = listener || nop;
//Stores prev value to compare
fs.stat(filename, function(err, stats) { prevStat = stats});
//stores interval return values //stores interval return values
statWatchers.set(filename, value); statWatchers.set(filename, value);
var value = setInterval(function() { var value = setInterval(function() {
fs.stat(filename, function(err, stats) { fs.stat(filename, function(err, stats) {
if(err) { if(err) {
//console.log(err); console.log(err);
}
currStat = stats;
if((currStat.mtime - prevStat.mtime) == 0) {
//No changes
}
else {
//if theres a difference file change
//call listener here
} }
//record file curr
//compare curr-prev
//if theres a difference file change
}); });
}, },
interval interval