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

ResourceWatcher misses some inotify events #3

Open
ju1ius opened this issue Aug 30, 2013 · 1 comment
Open

ResourceWatcher misses some inotify events #3

ju1ius opened this issue Aug 30, 2013 · 1 comment

Comments

@ju1ius
Copy link

ju1ius commented Aug 30, 2013

Steps to reproduce:

Setup test directory

cd /some/dir
composer.phar init
composer.phar require henrikbjorn/lurker dev-master
mkdir -p test/foo
touch test/foo/{bar,baz}.txt
vim test.php

Setup test script

// test.php
require_once __DIR__.'/vendor/autoload.php';
use Lurker\Event\FilesystemEvent;
use Lurker\ResourceWatcher;

$watcher = new ResourceWatcher();
$watcher->track('test.foo', __DIR__.'/test/foo');
$watcher->addListener('test.foo', function(FilesystemEvent $event) {
    echo $event->getTypeString() . ' >>> ' . $event->getResource() .PHP_EOL;
});
$watcher->start();

Open two terminals, t1 & t2

t1 $ php test.php
t2 $ echo "something" > test/foo/bar.txt
t1 > modify >>> [..]/test/foo/bar.txt
t2 $ mv test/foo/bar.txt test/
t1 > delete >> [..]/test/foo/bar.txt
t2 $ mv test/bar.txt test/foo/
t1 > ... # nothing !
t2 $ rm test/foo/bar.txt
t1 > ... # nothing !
t2 $ touch test/foo/bar.txt
t1 > create >> [..]/test/foo/bar.txt

Same session with inotifywait

t1 $ inotifywait -rm test/foo
t2 $ echo "something" > test/foo/bar.txt
t1 > test/foo/ MODIFY bar.txt
   > test/foo/ OPEN bar.txt
   > test/foo/ MODIFY bar.txt
   > test/foo/ CLOSE_WRITE,CLOSE bar.txt
t2 $ mv test/foo/bar.txt test/
t1 > test/foo/ MOVED_FROM bar.txt
t2 $ mv test/bar.txt test/foo/
t1 > test/foo/ MOVED_TO bar.txt
t2 $ rm test/foo/bar.txt
t1 > test/foo/ DELETE bar.txt
t2 $ touch test/foo/bar.txt
t1 > test/foo/ CREATE bar.txt
   > test/foo/ OPEN bar.txt
   > test/foo/ ATTRIB bar.txt
   > test/foo/ CLOSE_WRITE,CLOSE bar.txt

Conclusion

It seems Lurker is missing two events here. IN_MOVED_FROM (FilesystemEvent::DELETE) and IN_MOVED_TO (FilesystemEvent::CREATE).
Tested with pecl-inotify 0.1.6

$ php -i | grep inotify -A 2
> inotify
>
> Version => 0.1.1
@henrikbjorn
Copy link
Member

Would it be possible for you to maybe create a testcase that can be run on Travis? i dont have inotify installed.

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