Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recover from SMB failures [fix #293] #296

Merged
merged 1 commit into from
Mar 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

before { allow(dir).to receive(:children) { fail Errno::EHOSTDOWN } }

it 'reports no changes' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

expect(queue).to_not receive(:change)
described_class.scan(queue, record, dir, '.', options)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

end

it 'unsets record dir path' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

expect(async_record).to receive(:unset_path).with(dir, '.')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

described_class.scan(queue, record, dir, '.', options)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

end
end

context 'with file.rb in dir' do
before { allow(dir).to receive(:children) { [file] } }

Expand Down