Skip to content

Conversation

@kenhys
Copy link

@kenhys kenhys commented Nov 26, 2020

If same path is specified with :moved_from or :moved_to
additionally, :modify is not fired expectedly.

  require "rb-inotify"
  notifier = INotify::Notifier.new
  notifier.watch("test.log", :modify) do |event|
    puts "#{event} is modified"
  end
  notifier.watch("test.log", :moved_from) do |event|
    puts "#{event} is moved_from"
  end

Above sample code does not work as expected.
So, raise an error immediately.

If same path is specified with :moved_from or :moved_to
additionally, :modify is not fired expectedly.

  require "rb-inotify"
  notifier = INotify::Notifier.new
  notifier.watch("test.log", :modify) do |event|
    puts "#{event} is modified"
  end
  notifier.watch("test.log", :moved_from) do |event|
    puts "#{event} is moved_from"
  end

Above sample code does not work as expected.
So, raise an error immediately.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 80.556% when pulling bf2fc88 on kenhys:error-moved-to-file into 010f140 on guard:master.

@uvlad7
Copy link

uvlad7 commented Jun 23, 2025

I'd say it's just one of inotify's pitfalls and it's better to keep ruby wrapper as thin as possible
But if you stil want an check, I'd suggest adding IN_ONLYDIR flag if any of problematic flags are specified, but it still might be a problem for users if they pass the same flags for dirs and files

UPD: inotify doesn't have an 'event only for dirs' type, there are only events that can happen for files in a dir and both for a dir and files inside (note that these differences apply only when monitoring a directory); and

  require "rb-inotify"
  notifier = INotify::Notifier.new
  notifier.watch("test.log", :modify, :moved_from) do |event|
    puts "#{event} is modified"
  end

works fine.
Maybe it's a problem of inotify_add_watch itself?

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

Successfully merging this pull request may close these issues.

3 participants