Shail Patel
Shail Patel

Reputation: 1814

Rb-inotify can't tell when symlink changes

Here is the code:

require 'rb-inotify'

notifier = INotify::Notifier.new

notifier.watch("/path/to/folder", :moved_to, :create, :attrib, :modify) do |event|
   puts "I found #{event.name}!"
end

notifier.run

The folder is a symlink to another folder. I want to know when that symlink changes. For example I have /path/to/folder -> /link1 and when it changes to /path/to/folder -> /link2 I need to be able to tell. Currently I can change the underlying symlink and no events will be recorded. Is this possible using inotify or the ruby wrapper rb-inotify? Is there a better way of doing this?

Upvotes: 0

Views: 679

Answers (1)

CMoi
CMoi

Reputation: 846

You want to pass the flag IN_DONT_FOLLOW so that the symlink itself is watched, else it will watch /link1.

Upvotes: 1

Related Questions