Skip to content

Commit b01e901

Browse files
authored
[FS] Ensure parent node is always updated in rename(), regardless of backend (#21964)
Doing the update in the core logic avoids each backend needing to do it, and avoids the risk of a backend forgetting (as was the case with NODEFS, which this fixes).
1 parent ed95123 commit b01e901

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

src/library_fs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,9 @@ FS.staticInit();` +
812812
// do the underlying fs rename
813813
try {
814814
old_dir.node_ops.rename(old_node, new_dir, new_name);
815+
// update old node (we do this here to avoid each backend
816+
// needing to)
817+
old_node.parent = new_dir;
815818
} catch (e) {
816819
throw e;
817820
} finally {

src/library_memfs.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ addToLibrary({
198198
old_node.name = new_name;
199199
new_dir.contents[new_name] = old_node;
200200
new_dir.timestamp = old_node.parent.timestamp;
201-
old_node.parent = new_dir;
202201
},
203202
unlink(parent, name) {
204203
delete parent.contents[name];

src/library_proxyfs.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ addToLibrary({
108108
try {
109109
oldNode.mount.opts.fs.rename(oldPath, newPath);
110110
oldNode.name = newName;
111-
oldNode.parent = newDir;
112111
} catch(e) {
113112
if (!e.code) throw e;
114113
throw new FS.ErrnoError(ERRNO_CODES[e.code]);

0 commit comments

Comments
 (0)