Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong watch descriptor inside IN_DELETE_SELF #49

Open
digitalnature opened this issue Jan 27, 2015 · 3 comments
Open

Wrong watch descriptor inside IN_DELETE_SELF #49

digitalnature opened this issue Jan 27, 2015 · 3 comments

Comments

@digitalnature
Copy link

It looks like this event's object holds the watch descriptor associated with the parent directory, not for the directory that was just deleted. Basically it returns the same data as IN_DELETE

@c4milo
Copy link
Owner

c4milo commented Feb 2, 2015

hm weird, any code to reproduce?

@c4milo
Copy link
Owner

c4milo commented May 5, 2015

@digitalnature are you still seeing this behavior?

@digitalnature
Copy link
Author

Hey, sorry for the late response, I didn't get the chance to look into this again.

So I made a little script trying to reproduce the issue:

var Inotify = require('inotify').Inotify;
var fs = require('fs');
var ino = new Inotify();

var path1 = __dirname + '/a';
var path2 = __dirname + '/a/b';


var test = function(event){
  var mask = event.mask;
  if(mask & Inotify.IN_Q_OVERFLOW)
    console.log('event queue overflow');

  if(mask & Inotify.IN_IGNORED)
    console.log('watch removed, WD = ' + event.watch);

  if(mask & Inotify.IN_DELETE_SELF)
    console.log('delete_self, WD = ' + event.watch);

  if(mask & Inotify.IN_DELETE)
    console.log('delete, WD = ' + event.watch);

};

var wm = Inotify.IN_CREATE | Inotify.IN_DELETE | Inotify.IN_DELETE_SELF | Inotify.IN_MODIFY | Inotify.IN_CLOSE_WRITE | Inotify.IN_MOVE_SELF | Inotify.IN_MOVED_FROM | Inotify.IN_MOVED_TO;

fs.mkdirSync(path1);
ino.addWatch({ path: path1, watch_for: wm, callback: test });  // wd = 1

fs.mkdirSync(path2);
ino.addWatch({ path: path2, watch_for: wm, callback: test });  // wd = 2

setTimeout(function(){
  console.log('Removing sub dir...');  
  fs.rmdirSync(path2);
}, 1000);

setTimeout(function(){
  fs.rmdirSync(path1);
  ino.close();
  process.exit();  
}, 2500);

but here the event for IN_DELETE_SELF doesn't fire at all. Weird, because in the app that I'm working on I get it, but with the wrong wd. Perhaps it has something to do with the number of watches?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants