paulmillr / chokidar

Minimal and efficient cross-platform file watching library
https://paulmillr.com
MIT License
10.95k stars 580 forks source link

Rename folder with files sends first unlinkdir and then unlink for all files #1309

Closed yuvallevy135 closed 3 months ago

yuvallevy135 commented 7 months ago

Describe the bug

My flow is the following:

  1. create a dir.
  2. create some files in it.
  3. rename the folder.

well get an unlinkdir and only then unlink for all the files. The problem here when im trying to look for those unlink files the path doesnt exists anymore since the dir was already deleted. Is there a way to ensure that chokidar will perform unlink for all files under dir and only then the dir itseld?

Thank you!

Versions (please complete the following information):

To Reproduce:

Steps to reproduce the behavior. Include filename and chokidar config.

Ideally prove a problem by isolating and making it reproducible with a very short sample program, which you could paste here:

const chokidar = require('chokidar');
const fs = require('fs');
// One-liner for files and directories starting with 'test'
chokidar.watch('test*', {}).on('all', (event, path) => {
  console.log(event, path);
});
fs.writeFileSync('test.txt', 'testing 1');
// In a comment describe expected output versus observed problem

Most valuable could be one or more test cases for test.js to demonstrate the problem.

Expected behavior A clear and concise description of what you expect to happen.

Additional context Add any other context about the problem here. Optionally nice to know what project you are working on.