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

Avoid some unneccesary path resolution #23172

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

Conversation

hoodmane
Copy link
Collaborator

There are a bunch of codepaths where we have a node or a stream and we turn it back into a path, then eventually call lookupPath on it to turn it back into a node. This removes a few of these instances.

In general, I think it would be good to avoid stream.path in favor of stream.node, since we eventually will call lookupPath() to get back stream.node.

There are a bunch of codepaths where we have a node or a stream and we turn
it back into a path, then eventually call `lookupPath` on it to turn it back
into a node. This removes a few of these instances.
@hoodmane hoodmane force-pushed the avoid-path-resolution branch from 29efaf0 to 44979a6 Compare December 16, 2024 11:44
@@ -895,6 +896,9 @@ FS.staticInit();
FS.readdirNode(FS.lookupPath(path, { follow: true }).node);
},
readdirNode(node) {
if (!node.parent) {
return [];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any idea what these lines were supposed to be doing?

What does not having a parent mean? Is that only true for the root directory? Why would we want that to mean return the empty list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, if we've unlinked a directory we want to return empty list or raise ENOENT. By contrast, if the directory exists but is empty we return [".", ".."]. So we need to label the directory node as unlinked somehow when we unlink them. I can add a comment here saying that.

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