Giter VIP home page Giter VIP logo

Comments (13)

nex3 avatar nex3 commented on July 17, 2024

I can't reproduce this. The handler never gets unregistered for me.

from rb-inotify.

lym avatar lym commented on July 17, 2024

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.

eclubb avatar eclubb commented on July 17, 2024

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.

ytti avatar ytti commented on July 17, 2024

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.

eclubb avatar eclubb commented on July 17, 2024

I like the idea of hiding behind a :follow arg.

from rb-inotify.

nex3 avatar nex3 commented on July 17, 2024

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.

ytti avatar ytti commented on July 17, 2024

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.

nex3 avatar nex3 commented on July 17, 2024

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.

ytti avatar ytti commented on July 17, 2024

Completely okey with flag, just spitballing.

from rb-inotify.

digitalextremist avatar digitalextremist commented on July 17, 2024

I also see this failure to re-register events, under Ubuntu 14.04 with jRuby 1.7.12

from rb-inotify.

paoloaga avatar paoloaga commented on July 17, 2024

The solution is to handle the flag ":ignored" and re-instance the notifier.watch whenever you receive one.

from rb-inotify.

ioquatix avatar ioquatix commented on July 17, 2024

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.

ioquatix avatar ioquatix commented on July 17, 2024

Feel free to submit a failing PR either here or in the listen gem.

from rb-inotify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.