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

feat(ext/node): Promisify fstat and implement FileHandle#stat #26719

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

manzt
Copy link
Contributor

@manzt manzt commented Nov 4, 2024

Fixes #23301

Implements FileHandle.stat. This PR also adds a promisified fs.fstat under 'fs/promises', which is used internally by FileHandle.stat.

@manzt manzt force-pushed the manzt/fstat-promise branch 5 times, most recently from bd5b907 to bc98058 Compare November 4, 2024 18:09
@@ -152,7 +161,7 @@ function fsCall(fn, handle, ...args) {
});
}

return fn(handle, ...args);
return fn(handle.fd, ...args);
Copy link
Contributor Author

@manzt manzt Nov 4, 2024

Choose a reason for hiding this comment

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

Added a test as well for fh.writeFile() to make sure this change is OK.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should rather let fstat accept FileHandle, which improves the compatibility further (See this change for reference #25555 )

This fsCall util comes from this part in Node.js ( https://github.com/nodejs/node/blob/ccac4ee19d508abaf38bbabb87288ddeec7fcc21/lib/internal/fs/promises.js#L452-L470 ). I think it would be better to keep the code as aligned to node.js as possible.

@manzt manzt changed the title feat(ext/node): Implement FileHandle#stat feat(ext/node): Promisify fstat and implement FileHandle#stat Nov 4, 2024
@manzt
Copy link
Contributor Author

manzt commented Nov 4, 2024

Oops, seeing #24391. Feel free to close. Although, I don't think that PR handles checking the whether the file is open prior to executing the fs operations. Probably should use the fsCall wrapper.

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.

Node FileHandle#stat() not implemented
2 participants