Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fslib): fix FileHandle implementations #4410

Closed
wants to merge 1 commit into from

Conversation

mhassan1
Copy link
Contributor

What's the problem this PR addresses?
This PR fixes the following patchFs issues:

  • BREAKING CHANGE: promisified fs.write now returns an object
  • BREAKING CHANGE: handle.read now returns an object
  • BREAKING CHANGE: handle.write now returns an object
  • fix handle.truncate and other methods that expect path instead of fd

Resolves #4372.

How did you fix it?

  • I fixed the promisified fs.write implementation, similar to fix: Match promisified fs.read call return with original implementation #2128
  • I added handle.read and handle.write implementations that use promisified fs.read and fs.write
  • I added a non-enumerable property to FileHandle for storing the file handle path so it can be passed to methods like truncatePromise, which expect path instead of fd
  • I extended FILEHANDLE_IMPLEMENTATIONS to specify whether a method expects fd (e.g. readFilePromise) or path (e.g. truncatePromise)

Checklist

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@merceyz merceyz self-requested a review April 28, 2022 14:37
- BREAKING CHANGE: promisified `fs.write` now returns an object
- BREAKING CHANGE: `handle.read` now returns an object
- BREAKING CHANGE: `handle.write` now returns an object
- fix `handle.truncate` and other methods that expect `path` instead of `fd`
Copy link
Member

@merceyz merceyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a PR fixing the FileHandle implementation #3889.

I fixed the promisified fs.write implementation

Could you extract that to a separate PR?

I added a non-enumerable property to FileHandle for storing the file handle path so it can be passed to methods like truncatePromise, which expect path instead of fd

We can't use truncate we have to implement ftruncate and use that.

I extended FILEHANDLE_IMPLEMENTATIONS to specify whether a method expects fd (e.g. readFilePromise) or path (e.g. truncatePromise)

We can't just call the path version of the fs functions, we have to use the file descriptor versions.

@mhassan1
Copy link
Contributor Author

Thanks for the feedback. I didn't realize there was an outstanding PR for most of this. I am declining this PR.

@mhassan1 mhassan1 closed this Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug?]: filehandle.truncate(len) broken using yarn node
2 participants