Comments (13)
I can't reproduce this. The handler never gets unregistered for me.
from rb-inotify.
I was experiencing the same problem. Used @petur03 implementation and it works like I expected. I should probably mention that am running it against ruby-2.0.0-p0 on an Ubuntu 11.10 box.
from rb-inotify.
I had the same problem. For me, it was because I was editing my file with Vim. If I echoed text to the file, it worked fine.
I found the solution to my problem in this Super User answer: http://superuser.com/a/181543
I implemented his solution as such:
require 'rb-inotify'
notifier = INotify::Notifier.new
notifier.watch('.', :close_write, :moved_to, :create) do |event|
puts 'dummy.txt was updated' if event.name == 'dummy.txt'
end
notifier.run
This detects the change whether the file is written to directly or replaced with another file.
from rb-inotify.
Yeah I think this is expected, it's monitoring specific inode, and editors regularly delete file and write new one, so you'll just get delete event and that's it, inode you're watching is gone.
Maybe high-level API should have option to follow file name, essentially implement solution like eclubb's when given argument like :follow?
from rb-inotify.
I like the idea of hiding behind a :follow
arg.
from rb-inotify.
I'm fine with having a flag for this, but I'm not a fan of the name :follow
; it sounds like it's referring to symlinks somehow. I'd prefer something like :resubscribe
.
from rb-inotify.
No contest on name, fine with any. Another method is also option, perhaps #watch_name, would avoid overloading configuration arguments with event types and have more obvious fail with older versions of API ran against code using it.
from rb-inotify.
We already overload configuration arguments for :recursive
, but you make a good point about providing an obvious error. We should really be throwing an error for unrecognized flags anyway.
I think I slightly prefer a flag, since that allows flags to compose more seamlessly.
from rb-inotify.
Completely okey with flag, just spitballing.
from rb-inotify.
I also see this failure to re-register events, under Ubuntu 14.04
with jRuby 1.7.12
from rb-inotify.
The solution is to handle the flag ":ignored" and re-instance the notifier.watch whenever you receive one.
from rb-inotify.
Now that we have test, it would be great to add a spec for this including some documentation for the correct way this should be handled.
from rb-inotify.
Feel free to submit a failing PR either here or in the listen gem.
from rb-inotify.
Related Issues (20)
- Compiled C Extension Non-FFI Tools?
- Upgrading old application from Ruby 1.8.7 to 2.7.4, getting error about RUBY_ENGINE in ffi
- Got Errno::ENOSYS with docker linux/amd64 on arm64 m1 mac with Rails HOT 5
- Feature request - filter paths in :recursive mode
- Better coordination/shared organisation HOT 47
- Breaking change in 0.9.9 from 0.9.8 HOT 23
- New child directory not being watched HOT 3
- Build failure on JRuby HOT 11
- Activating watchers
- Strange behavior of :delete_self HOT 1
- stack level too deep when running with musl on Alpine HOT 1
- Allows versions of ffi (1.9.22, 1.9.23) that throw SIGABRT (RHEL/Centos) or Segfault (MacOS) HOT 4
- Recursive flag does not watch files in subdirectories HOT 4
- Test on 2.6 HOT 1
- JRuby shows Thread termination exceptions with 0.10.0. HOT 12
- Starting Rails Server fails on Raspberry PI 3 B+ HOT 10
- Get UID/Username of a deleted file or folder entry HOT 5
- Update ruby-ffi version
- inotify somehow missing modification events for dropbox file
- warning: rb_safe_level will be removed in Ruby 3.0 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rb-inotify.