From 8e1b6692e81285fb1a0df995625ec988d5985d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juha=20Erkkil=C3=A4?= Date: Wed, 4 Jan 2017 12:27:03 +0200 Subject: [PATCH] Do not follow into symlinked directories when traversing directories and :dont_follow and :recursive are in effect. --- lib/rb-inotify/notifier.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rb-inotify/notifier.rb b/lib/rb-inotify/notifier.rb index c2f6ddc..d81d990 100644 --- a/lib/rb-inotify/notifier.rb +++ b/lib/rb-inotify/notifier.rb @@ -195,7 +195,11 @@ def watch(path, *flags, &callback) d = File.join(path, base) binary_d = d.respond_to?(:force_encoding) ? d.dup.force_encoding('BINARY') : d next if binary_d =~ /\/\.\.?$/ # Current or parent directory - watch(d, *flags, &callback) if !RECURSIVE_BLACKLIST.include?(d) && File.directory?(d) + next if RECURSIVE_BLACKLIST.include?(d) + next if flags.include?(:dont_follow) && File.symlink?(d) + next if !File.directory?(d) + + watch(d, *flags, &callback) end dir.close