c4milo / node-inotify

Inotify bindings for Node.JS
http://c4milo.github.io/node-inotify
MIT License
243 stars 39 forks source link

There are several events that aren't registering - Reported by AJ ONeal #5

Closed c4milo closed 13 years ago

c4milo commented 13 years ago

There are several events that aren't registering with my tests:

At least IN_MOVE, IN_MOVED_TO, IN_MOVED_FROM, and IN_DELETE, maybe more.

I added this to the example in the readme and change the directory, of course

} else if(mask & Inotify.IN_MOVED_FROM) {
    sys.puts(type + 'was moved from');
} else if(mask & Inotify.IN_MOVED_TO) {
    sys.puts(type + 'was moved to');

Here's my test

!/bin/bash

mkdir test-inotify node test-inotify.js > output.txt & sleep 1; cd test-inotify touch foo mv foo ../ mv ../foo ./ mv foo bar rm bar cd ../ rm test-inotify -rf

Output:

File foo was opened File foo opened for writing was closed Directory was opened Directory opened for reading was closed File watch was removed

any ideas as to why that would be?

I installed inotify-tools and ran inotifywatch ./test-inotify to make sure it wasn't a problem with my architecture or file system

inotifywatch -r test-inotify Establishing watches... Finished establishing watches, now collecting statistics. total attrib close_write open moved_from moved_to create delete filename 9 1 1 1 2 2 1 1 test-inotify/

c4milo commented 13 years ago

Hi AJ,

I hope you are doing well.

Where did you install the watch ? be aware that inotify isn't recursive. That means that if you didn't add the watch over the test-inotify directory, any event within it won't be reported.

I moved this issue to http://github.com/c4milo/node-inotify/issues/issue/5 to continue the discussion there.

Warm regards,

Camilo Aguilar

coolaj86 commented 13 years ago

Yes, I did change the directory to be /home/user/test-inotify. Notice the output - it sees that the file is opened for writing and closed, but it doesn't see that the file was moved or deleted.

coolaj86 commented 13 years ago

Oops, my bad! I didn't notice restriction on watching the events.

watch_for: Inotify.IN_OPEN | Inotify.IN_CLOSE

I commented that out and it worked as expected. All is well after all.

Thank your very much for you work on this, btw.

c4milo commented 13 years ago

your welcome :)