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

Ensure parent node is always updated in rename(), regardless of fs implementation #21964

Merged
2 changes: 2 additions & 0 deletions src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,8 @@ FS.staticInit();` +
// changed its name)
FS.hashAddNode(old_node);
}
// update old node (we do this here to avoid each backend needing to)
old_node.parent = new_dir;
#if FS_DEBUG
if (FS.trackingDelegate['onMovePath']) {
FS.trackingDelegate['onMovePath'](old_path, new_path);
Expand Down
1 change: 0 additions & 1 deletion src/library_memfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ addToLibrary({
old_node.name = new_name;
new_dir.contents[new_name] = old_node;
new_dir.timestamp = old_node.parent.timestamp;
old_node.parent = new_dir;
},
unlink(parent, name) {
delete parent.contents[name];
Expand Down
1 change: 0 additions & 1 deletion src/library_proxyfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ addToLibrary({
try {
oldNode.mount.opts.fs.rename(oldPath, newPath);
oldNode.name = newName;
oldNode.parent = newDir;
} catch(e) {
if (!e.code) throw e;
throw new FS.ErrnoError(ERRNO_CODES[e.code]);
Expand Down