streamich / unionfs

Use multiple fs modules at once
https://www.npmjs.com/package/unionfs
The Unlicense
205 stars 24 forks source link

fix: `createWriteStream` failing to create new files in directories #783

Closed dy-dx closed 6 months ago

dy-dx commented 6 months ago

This issue provides most of the context: https://github.com/streamich/unionfs/issues/428

428 suggests just to replace fs.statSync(path) with fs.statSync(dirname(path)), but that could cause surprising behavior in the case where multiple filesystems include the parent directory.

I've added a regression test for this case: "createWriteStream writes to an existing file even if parent dir exists on an earlier fss"

Fixes #428

dy-dx commented 6 months ago

I've just noticed that unionfs iterates backwards through the this.fss array for most operations, except when using createWriteStream/createReadStream.

This seems like a mistake, and I'll address it in ~this PR as well~.

Addressed in https://github.com/streamich/unionfs/pull/785

github-actions[bot] commented 6 months ago

:tada: This PR is included in version 4.5.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: