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

Tell apart hardlinks from changes to a file #570

Closed
IvanSanchez opened this issue Jan 20, 2017 · 2 comments
Closed

Tell apart hardlinks from changes to a file #570

IvanSanchez opened this issue Jan 20, 2017 · 2 comments

Comments

@IvanSanchez
Copy link

A bit of background: I recently developed https://github.com/gobblejs/gobble-hardlink , a plugin for the GobbleJS build tool. Hardlinking stuff in my workflow works fine in individual runs, but turns into an infinite loop when running the build tool in watch mode (see also gobblejs/gobble#129 ).

I managed to track down the cause to chokidar's behaviour when hardlinking a file: it is reported as a change in the file.

So if cp src dest doesn't change the file, and neither does ln -s src dest, then why ln src dest is reported as a change? My educated guess is that the hardlink count is increased in the filesystem, and this is reported as a change in the file entry, even though the file contents, the inodes, and the modification time of the file did not change.

I would very much like to tell apart changes to a file from hardlink creations. I don't know if chokidar caches the results from fs.stats - if it does, it would be possible to use mtime and/or nlink to tell apart hardlinkings. API-wise I'd love to have a new 'hardlink' event.

@es128
Copy link
Contributor

es128 commented Jan 20, 2017

Chokidar relies on other subsystems to report changes, and they may differ in behavior for your use case. You could try usePolling: true to use fs.watchFile under the hood and see if that impacts the behavior relating to hardlinks.

Regardless, it's out of scope for chokidar to try to characterize the nature of the reported change event in the way you're asking. It's something you're going to have to figure out how to cope with upstream. You can use the alwaysStat: true option if it helps.

@es128 es128 closed this as completed Jan 20, 2017
@IvanSanchez
Copy link
Author

Sad to hear that, but it's understandable. I'll try to hack something upstream.

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

No branches or pull requests

2 participants