forked from nodejs/node
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs: fixes recursive fs.watch crash on Linux when deleting files
Signed-off-by: Matteo Collina <[email protected]> Fixes: nodejs#52018
- Loading branch information
Showing
2 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict' | ||
|
||
const common = require('../common') | ||
const tmpdir = require('../common/tmpdir'); | ||
const fs = require('fs') | ||
const { join } = require('path') | ||
const assert = require('node:assert') | ||
|
||
tmpdir.refresh(); | ||
|
||
try { | ||
fs.mkdirSync(tmpdir.resolve('./parent/child'), { recursive: true }) | ||
} catch (e) { | ||
console.error(e) | ||
} | ||
|
||
fs.writeFileSync(tmpdir.resolve('./parent/child/test.tmp'), 'test') | ||
|
||
const watcher = fs.watch(tmpdir.resolve('./parent'), { recursive: true }, common.mustCall((eventType, filename) => { | ||
// We are only checking for the filename to avoid having Windows, Linux and Mac specific assertions | ||
assert.strictEqual(filename.indexOf('test.tmp') >= 0, true) | ||
watcher.close() | ||
})) | ||
|
||
fs.rmSync(tmpdir.resolve('./parent/child/test.tmp')) |