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

Return EISDIR when trying to create a path ending in / with open #23135

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

Conversation

hoodmane
Copy link
Collaborator

If we open a path that in a / and we're about to create a file, instead return EISDIR.

If we open a path that in a / and we're about to create a file, instead return EISDIR.
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

lgtm % comments

src/library_fs.js Outdated Show resolved Hide resolved
test/fs/test_fs_eisdir.c Outdated Show resolved Hide resolved
@@ -1053,9 +1053,11 @@ FS.staticInit();
mode = 0;
}
var node;
var isDirPath;
if (typeof path == 'object') {
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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?

Copy link
Collaborator

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.

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.

2 participants