Skip to content

Gracefully deal with dangling symlinks #522

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

Merged
merged 2 commits into from
May 20, 2017

Conversation

jeremy
Copy link
Member

@jeremy jeremy commented May 18, 2017

Gracefully deal with dangling symlinks

  • Don't add files that are dangling symlinks
  • When watching a directory, ignore dangling symlinks rather than treating them as forever-stale

Add a watcher logging facility so such things can be diagnosed and debugged.

@jeremy jeremy force-pushed the watch-dangling-symlinks branch 2 times, most recently from 0ce76f5 to c6733ec Compare May 18, 2017 17:44
Copy link
Member

@jonleighton jonleighton left a comment

Choose a reason for hiding this comment

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

👍 Looks good in general, I have some code style differences but... whatevs :)


@watcher.on_debug do |message|
spring_env.log "[watcher:#{app_env}] #{message}"
end if @watcher.respond_to?(:on_debug)
Copy link
Member

Choose a reason for hiding this comment

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

Why is the conditional needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Only the poller watcher implements it. Calling it on the listen watcher would bomb.

Copy link
Member

Choose a reason for hiding this comment

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

But it's defined in the abstract class which the listen watcher inherits from?

item.readlink.exist?.tap do |exists|
debug do
"add: ignoring dangling symlink: #{item.inspect} -> #{item.readlink.inspect}"
end if !exists
Copy link
Member

Choose a reason for hiding this comment

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

Not really a fan of this style of postfix conditional on a multi-line block personally (I think it's harder to spot what the conditional is doing...)

@jeremy jeremy force-pushed the watch-dangling-symlinks branch 2 times, most recently from 21dc781 to f923cf1 Compare May 20, 2017 23:08
jeremy added 2 commits May 20, 2017 16:09
* Don't add files that are dangling symlinks
* When watching a directory, ignore dangling symlinks rather than treating them as forever-stale
@jeremy jeremy force-pushed the watch-dangling-symlinks branch from f923cf1 to 59bde9e Compare May 20, 2017 23:09
@jeremy jeremy merged commit 87dc8ce into rails:master May 20, 2017
@jeremy jeremy deleted the watch-dangling-symlinks branch May 20, 2017 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants