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

Incorrect event firing on macOS when filename case changes #1280

Open
george-thomas-hill opened this issue Apr 8, 2023 · 1 comment
Open

Comments

@george-thomas-hill
Copy link

On a case-insensitive (i.e. typical) APFS drive, when a filename changes case, incorrect events fire.

If a filename starts off as "scratch.txt", when it is changed to "Scratch.txt" the following events fire:

change /Users/georgehill/Desktop/parent/scratch.txt
add /Users/georgehill/Desktop/parent/Scratch.txt

However, I would expect to see:

unlink /Users/georgehill/Desktop/parent/scratch.txt
add /Users/georgehill/Desktop/parent/Scratch.txt

If the file is then changed from "Scratch.txt" to "SCratch.txt", the following events fire:

change /Users/georgehill/Desktop/parent/Scratch.txt
add /Users/georgehill/Desktop/parent/SCratch.txt

That is consistent with the events that fired when going from "scratch.txt" to "Scratch.txt".

However, if the filename later changes from "SCRatch.txt" back to "scratch.txt" (e.g. a prior casing), then the following events fire:

change /Users/georgehill/Desktop/parent/SCRatch.txt
change /Users/georgehill/Desktop/parent/scratch.txt

Notice that this change is not consistent with the prior changes: it's two change events, not a change followed by an add.

Versions (please complete the following information):

  • Chokidar version: 3.5.3
  • Node version: 18.13.0
  • OS version: macOS 12.6.3

To Reproduce:

See above.

I used the following simple index.js code:

const chokidar = require('chokidar');

chokidar.watch('/Users/georgehill/Desktop/parent').on('all', (event, path) => {
    console.log(event, path);
});

And I started with a file named "scratch.txt".

Expected behavior

See above.

Additional context

I expect that this problem occurs because typical macOS drives are case insensitive.

@pedroferreira37
Copy link

Hi, @george-thomas-hill

This kind of issue usually happens in directories, exactly as you mentioned. In your case, since we talking about files, it appears to be a design choice rather than a problem with the SO. In the event 'all', seems that it only triggers for event 'change' and event 'add'. I think this could actually be considered a feature implementation request.

Having spent some time familiarizing myself with the codebase, I want to contribute and would like to offer my help in this issue.

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