ewollesen / autotest-inotify

Teaches autotest to use inotify (on Linux) instead of filesystem polling.
http://kill-0.com/projects/autotest-inotify
MIT License
18 stars 7 forks source link

file changes with gedit don't get a notification #5

Closed ghost closed 14 years ago

ghost commented 14 years ago

Editing a file with gedit didn't trigger notifications. Since each file_change with gedit triggers a "moved_to" event, I changed the

def setup_inotify @notifier = INotify::Notifier.new files = self.find_files.keys dirs = files.map{|f| File.dirname( f )}.uniq

Watch directories to catch delete/move swap patterns as well as direct

# modifications.  This handles, e.g. :w in vim.
dirs.each do |dir|
  @notifier.watch( dir, :all_events ) do |event|
    if  event.flags.include? :modify and
        files.include? event.absolute_name
      handle_file_event( event )
    end
  end
end

end

to the following code

def setup_inotify @notifier = INotify::Notifier.new files = self.find_files.keys dirs = files.map{|f| File.dirname( f )}.uniq

Watch directories to catch delete/move swap patterns as well as direct

# modifications.  This handles, e.g. :w in vim.
dirs.each do |dir|
  @notifier.watch( dir, :all_events ) do |event|
    if  event.flags.include? :modify and
        files.include? event.absolute_name
      handle_file_event( event )
    elsif event.flags.include? :moved_to and
        files.include? event.absolute_name
      handle_file_event( event )
    end
  end
end

end

ewollesen commented 14 years ago

Thanks for the report, sorry for the delay. I've pushed changes to incorporate your discovery. Please re-open is there are still problems.

PS- sorry for the slow response, personal issues have kept me away.