Permalink
Browse files

Improve INotify support on linux (fixes #79 #82)

Improve usage with several text editors that writes to temporal
files and then move over the original filename instead of write
files directly. Tested with GEdit, Nano, vim (with 'set backup'
and 'set nobackup') and emacs.
  • Loading branch information...
Gazer authored and yannlugrin committed Jun 17, 2011
1 parent 975444b commit d51b457b71567145d0fba6529b6d08287c3f8db1
Showing with 12 additions and 1 deletion.
  1. +1 −1 lib/guard/listeners/linux.rb
  2. +11 −0 spec/guard/listeners/linux_spec.rb
@@ -47,7 +47,7 @@ def worker
end
def watch(directory)
- worker.watch(directory, :recursive, :modify, :create) do |event|
+ worker.watch(directory, :recursive, :modify, :create, :close_write) do |event|
unless event.name == "" # Event on root directory
@files << event.absolute_name
end
@@ -50,6 +50,17 @@
# Fun fact: File.touch seems not to be enough on Linux to trigger a modify event
+ it "catches a write_close event" do
+ @listener = described_class.new
+ record_results
+ file = @fixture_path.join("folder1/file1.txt")
+ File.exists?(file).should be_true
+ start
+ File.open(file, 'r+').close
+ stop
+ results.should =~ ['spec/fixtures/folder1/file1.txt']
+ end
+
it "doesn't process a change when it is stopped" do
@listener = described_class.new
record_results

0 comments on commit d51b457

Please sign in to comment.