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
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@ FS.staticInit();
#endif
parent.node_ops.rmdir(parent, name);
FS.destroyNode(node);
node.parent = null;
#if FS_DEBUG
if (FS.trackingDelegate['onDeletePath']) {
FS.trackingDelegate['onDeletePath'](path);
Expand All @@ -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.

if (!node.node_ops.readdir) {
throw new FS.ErrnoError({{{ cDefs.ENOTDIR }}});
}
Expand Down
Loading