java8 watcher.js no work
wadang opened this issue · 0 comments
java7 watcher.js work well.
but in java8,there is a very magical error, is it no one encountered it ?
The same timestamp is not equal after comparison。
function fileWatcher(calledCallbacks) {
for (var file in filesWatched) {
var fileObject = new File(file);
var lm = fileObject.lastModified();
console.log("lm="+lm);
console.log("filesWatched[file].lastModified="+filesWatched[file].lastModified);
console.log("lm != filesWatched[file].lastModified is "+(lm != filesWatched[file].lastModified));
if ( String(lm) != String( filesWatched[file].lastModified) ) {
filesWatched[file].lastModified = lm;
filesWatched[file].callback(fileObject);
if (!fileObject.exists()) {
exports.unwatchFile(file,filesWatched[file].callback);
}
}
}
};
run :
[14:35:24] [Server thread/INFO]: lm=1481177969000
[14:35:24] [Server thread/INFO]: filesWatched[file].lastModified=1481177969000
[14:35:24] [Server thread/INFO]: lm != filesWatched[file].lastModified is true
function fileWatcher(calledCallbacks) {
for (var file in filesWatched) {
var fileObject = new File(file);
var lm = fileObject.lastModified();
console.log('typeof lm = '+(typeof lm) );
console.log('typeof filesWatched[file].lastModified = ' +(typeof filesWatched[file].lastModified) );
console.log(' lm !=filesWatched[file].lastModified) is ' +(lm != filesWatched[file].lastModified));
};
console return
[13:56:02] [Server thread/INFO]: typeof lm = object
[13:56:02] [Server thread/INFO]: typeof filesWatched[file].lastModified = object
[13:56:02] [Server thread/INFO]: lm !=filesWatched[file].lastModified) is true