【问题标题】:Rb-inotify can't tell when symlink changesRb-inotify 无法判断符号链接何时更改
【发布时间】:2014-03-25 22:41:29
【问题描述】:

代码如下:

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

该文件夹是另一个文件夹的符号链接。我想知道该符号链接何时更改。例如,我有/path/to/folder -> /link1,当它更改为/path/to/folder -> /link2 时,我需要能够分辨出来。目前我可以更改底层符号链接,并且不会记录任何事件。这可以使用 inotify 或 ruby​​ 包装器 rb-inotify 吗?有没有更好的方法来做到这一点?

【问题讨论】:

    标签: ruby linux unix inotify


    【解决方案1】:

    您想传递标志 IN_DONT_FOLLOW 以便监视符号链接本身,否则它将监视 /link1

    【讨论】:

    • 一旦符号链接更改,它不会注意到符号链接是否再次更改。我想这是预期的行为。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-24
    • 2013-02-12
    • 1970-01-01
    • 2019-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多