chokidar icon indicating copy to clipboard operation
chokidar copied to clipboard

awaitWriteFinish causes some symlinks to be followed

Open redneb opened this issue 4 years ago • 0 comments

Describe the bug

When I enable the awaitWriteFinish (as well as alwaysStat and having followSymlinks disabled), then when a symlink to a regular file is created the Stats parameter passed to the event callback reports that the file is a regular file and not a symlink. This only happens for symlinks created after the ready event.

Versions (please complete the following information):

  • Chokidar version: 3.3.1
  • Node version: 12.13.1
  • OS version: Linux x86_64

To Reproduce:

The following is a minimal example to reproduce this:

const chokidar = require("chokidar");
const fs = require("fs");

fs.rmdirSync("test", {recursive: true}); // remove the temp dir from previous runs
fs.mkdirSync("test", {recursive: true}); // create the temp dir

chokidar.watch("test", {
	awaitWriteFinish: true,
	followSymlinks: false,
	alwaysStat: true,
}).on("all", (ev, path, st) => {
	if (path === "test/symlink.txt" && st)
		console.log(ev, st.isSymbolicLink(), st.isFile());
}).on("ready", () => {
	fs.writeFileSync("test/test.txt", "test\n");
	fs.symlinkSync("test.txt", "test/symlink.txt");
});

Expected behavior

I expected that the above script will print true false, but instead it prints false true. If I set awaitWriteFinish to true then it works as expected.

redneb avatar Dec 17 '19 12:12 redneb