-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Return EISDIR when trying to create a path ending in / with open #23135
base: main
Are you sure you want to change the base?
Conversation
If we open a path that in a / and we're about to create a file, instead return EISDIR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm % comments
@@ -1053,9 +1053,11 @@ FS.staticInit(); | |||
mode = 0; | |||
} | |||
var node; | |||
var isDirPath; | |||
if (typeof path == 'object') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reading this makes me think we should avoid this type of polymorphic input types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it does complicate code. In a few places, it helps avoid wasteful roundtripping if we need to call an API that expects a path but we have a node. But we could have differently named methods e.g., openPath
and openNode
rather than one that tries to handle both. And there are a lot of spots where we already are being wasteful. For example, lookupPath
probably ought to have a relative form where it takes a base directory node to start at.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think separating openPath
from openNode
would be a great idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we make any backwards compatibility guarantees about the FS api?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats a good question. I there it is documented so at the very least we would want to document any changes in the changelog and update the docs.
If we open a path that in a / and we're about to create a file, instead return EISDIR.