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
3 changes: 3 additions & 0 deletions src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,9 @@ FS.staticInit();` +
// do the underlying fs rename
try {
old_dir.node_ops.rename(old_node, new_dir, new_name);
// update old node (we do this here to avoid each backend
// needing to)
old_node.parent = new_dir;
} catch (e) {
throw e;
} finally {
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
Loading