From d78ecb45fb784b08c3823984eb04f5448c5ffc1e Mon Sep 17 00:00:00 2001 From: Michael Kessler Date: Thu, 30 Jun 2011 09:23:12 +0200 Subject: [PATCH] Change inotify event flags (Closes #12). There have been some issues with Guard in Linux, which all lead back to the selection of the proper inotify flags. It seems that almost each editors behaves different when it comes to save a file. @jeffutter started to collect information about these events, which are now listed in the Guard wiki: https://github.com/guard/guard/wiki/Analysis-of-inotify-events-for-different-editors If you miss your favorite editor, please add your analysis to the list. --- CHANGELOG.md | 2 ++ lib/guard/listeners/linux.rb | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64e236e..3efe36a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ## Improvements +- Issue [#98](https://github.com/guard/guard/issues/98): Multiple calls per watch event on linux with rb-inotify. ([@jeffutter][] & [@netzpirat][]) - Pull request [#94](https://github.com/guard/guard/pull/94): Show backtrace in terminal when a problem with a watch action occurs. ([@capotej][]) - Pull request [#88](https://github.com/guard/guard/pull/88): Write exception trace in the terminal when a supervised task fail. ([@mcmire][]) - Color in red the "ERROR:" flag when using `UI.error`. ([@rymai][]) @@ -170,6 +171,7 @@ [@gix]: https://github.com/gix [@hashrocketeer]: https://github.com/hashrocketeer [@indirect]: https://github.com/indirect +[@jeffutter]: https://github.com/jeffutter [@johnbintz]: https://github.com/johnbintz [@jrsacks]: https://github.com/jrsacks [@koshigoe]: https://github.com/koshigoe diff --git a/lib/guard/listeners/linux.rb b/lib/guard/listeners/linux.rb index f456fad..35c465a 100644 --- a/lib/guard/listeners/linux.rb +++ b/lib/guard/listeners/linux.rb @@ -47,7 +47,8 @@ module Guard end def watch(directory) - worker.watch(directory, :recursive, :modify, :create, :close_write) do |event| + # The event selection is based on https://github.com/guard/guard/wiki/Analysis-of-inotify-events-for-different-editors + worker.watch(directory, :recursive, :create, :move_self, :close_write) do |event| unless event.name == "" # Event on root directory @files << event.absolute_name end