streamich / memfs

JavaScript file system utilities
http://streamich.github.io/memfs/
Apache License 2.0
1.75k stars 130 forks source link

Files can incorrectly be nested inside other files #1049

Closed NotWearingPants closed 4 weeks ago

NotWearingPants commented 3 months ago

It's possible to read/write files nested inside other files:

const { fs } = require('memfs');
fs.writeFileSync('/foo', 'hello');
fs.writeFileSync('/foo/bar', 'world');
console.log(fs.readFileSync('/foo', 'utf8')); // logs 'hello'
console.log(fs.readFileSync('/foo/bar', 'utf8')); // logs 'world'
console.log(fs.statSync('/foo').isFile()); // logs 'true'
console.log(fs.statSync('/foo').isDirectory()); // logs 'false'
console.log(fs.readdirSync('/foo')); // throws ENOTDIR

/foo is a regular file, and bar is also a regular file that's nested in /foo.

Tested with v4.11.1

G-Rath commented 3 months ago

Yup that's a bug alright

Kenny4297 commented 3 months ago

Hi @NotWearingPants, I think I may be able to help with this issue. I would love to be assigned to it if possible!

G-Rath commented 3 months ago

@Kenny4297 go for it!

BadIdeaException commented 1 month ago

@G-Rath This is fixed in 4.12.0. This issue can be closed now, as well as #1052.

G-Rath commented 4 weeks ago

@BadIdeaException do you know if we've got a test to guard against future regression?

BadIdeaException commented 4 weeks ago

Yes, we do: openSync.test.ts tests this exact scenario.

NotWearingPants commented 3 weeks ago

(For future reference: this issue was fixed by #1059)