From 945152461a6cf7b70c2ac417743155ea08d82fbd Mon Sep 17 00:00:00 2001 From: Cezary Baginski Date: Mon, 9 Mar 2015 11:20:20 +0100 Subject: [PATCH] recover from SMB failures [fix #293] --- lib/listen/directory.rb | 2 +- spec/lib/listen/directory_spec.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/listen/directory.rb b/lib/listen/directory.rb index 1b0b6185..7f067205 100644 --- a/lib/listen/directory.rb +++ b/lib/listen/directory.rb @@ -30,7 +30,7 @@ def self.scan(queue, sync_record, dir, rel_path, options) _async_changes(dir, rel_path, queue, previous, options) - rescue Errno::ENOENT + rescue Errno::ENOENT, Errno::EHOSTDOWN record.unset_path(dir, rel_path) _async_changes(dir, rel_path, queue, previous, options) diff --git a/spec/lib/listen/directory_spec.rb b/spec/lib/listen/directory_spec.rb index 54338279..1a8398ce 100644 --- a/spec/lib/listen/directory_spec.rb +++ b/spec/lib/listen/directory_spec.rb @@ -86,6 +86,20 @@ end end + context 'when network share is disconnected' do + before { allow(dir).to receive(:children) { fail Errno::EHOSTDOWN} } + + it 'reports no changes' do + expect(queue).to_not receive(:change) + described_class.scan(queue, record, dir, '.', options) + end + + it 'unsets record dir path' do + expect(async_record).to receive(:unset_path).with(dir, '.') + described_class.scan(queue, record, dir, '.', options) + end + end + context 'with file.rb in dir' do before { allow(dir).to receive(:children) { [file] } }