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

Compute the SHA1 sum only for regular files #85

Closed
wants to merge 3 commits into from

Conversation

antifuchs
Copy link
Contributor

The current checksumming code in directory_record.rb's content_modified? method will attempt to open & compute the checksum of any directory entry that comes up as changed. On OS X at least, that will also try and compute the checksum of local sockets and FIFOs, which not only fails but also confuses any program on the other side of that dirent.

This change checks for the regular-fileness of a changed directory entry and simply doesn't count those as having had their content changed if they're not a regular file.

I am pretty sure that this PR as it is doesn't pass muster (there's no test for it), but would like to submit it for discussion anyway. What would be the ideal way to test this? Should I make it a platform-specific test for Darwin (where I can reproduce the issue)?

This disables checksumming for all char/block devices, FIFOs, sockets
that may have been shown as having changed, and only checksums regular
ones. This allows compatibility between Guard and Zeus (and
potentially, some weird ssh ControlSocket games).
@thibaudgg
Copy link
Member

Looks great, yeah at least a OS X / Linux (travis-ci) spec would be nice. Thanks!

This creates a UNIX domain socket (not compatible with Windows) and
"modifies" it - a correctly working Listen should not attempt to SHA1
that file (as it confuses servers).
@antifuchs
Copy link
Contributor Author

This should do it - the test case fails without the commit fixing the problem above and succeeds with it. I've made it conditional on not running on windows (and it tests for the case of unix local sockets). Hope that's ok!

@thibaudgg
Copy link
Member

unix_server_socket doesn't seems to be compatible with Ruby 1.8 either: https://travis-ci.org/guard/listen/builds/4783087

@thibaudgg thibaudgg closed this in 81030fd Apr 6, 2013
@antifuchs antifuchs deleted the sha1-only-regular-files branch April 6, 2013 16:41
thibaudgg added a commit that referenced this pull request Apr 6, 2013
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.

2 participants