Skip to content

Commit

Permalink
recover from SMB failures [fix #293]
Browse files Browse the repository at this point in the history
  • Loading branch information
e2 committed Mar 9, 2015
1 parent d0526e0 commit 9451524
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/listen/directory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions spec/lib/listen/directory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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] } }

Expand Down

0 comments on commit 9451524

Please sign in to comment.