From 7988dc9adf50468adf61dc3f068b6b79cecf749e Mon Sep 17 00:00:00 2001 From: KernelDeimos <7225168+KernelDeimos@users.noreply.github.com> Date: Thu, 6 Nov 2025 16:15:48 -0500 Subject: [PATCH] dev(puterfs): move 'move' to extension --- extensions/puterfs/main.js | 41 +++++++++++++++++ .../modules/puterfs/lib/PuterFSProvider.js | 45 +------------------ 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/extensions/puterfs/main.js b/extensions/puterfs/main.js index 32a7f7a74..99df069a8 100644 --- a/extensions/puterfs/main.js +++ b/extensions/puterfs/main.js @@ -449,6 +449,47 @@ class PuterFSProvider { return node; } + async move ({ context, node, new_parent, new_name, metadata }) { + const old_path = await node.get('path'); + const new_path = path_.join(await new_parent.get('path'), new_name); + + const op_update = await svc_fsEntry.update(node.uid, { + ...( + await node.get('parent_uid') !== await new_parent.get('uid') + ? { parent_uid: await new_parent.get('uid') } + : {} + ), + path: new_path, + name: new_name, + ...(metadata ? { metadata } : {}), + }); + + node.entry.name = new_name; + node.entry.path = new_path; + + // NOTE: this is a safeguard passed to update_child_paths to isolate + // changes to the owner's directory tree, ut this may need to be + // removed in the future. + const user_id = await node.get('user_id'); + + await op_update.awaitDone(); + + await svc_fs.update_child_paths(old_path, node.entry.path, user_id); + + const promises = []; + promises.push(svc_event.emit('fs.move.file', { + context, + moved: node, + old_path, + })); + promises.push(svc_event.emit('fs.rename', { + uid: await node.get('uid'), + new_name, + })); + + return node; + } + async #rmnode ({ node, options }) { // Services if ( !options.override_immutable && await node.get('immutable') ) { diff --git a/src/backend/src/modules/puterfs/lib/PuterFSProvider.js b/src/backend/src/modules/puterfs/lib/PuterFSProvider.js index f43b42e9d..0105e28a5 100644 --- a/src/backend/src/modules/puterfs/lib/PuterFSProvider.js +++ b/src/backend/src/modules/puterfs/lib/PuterFSProvider.js @@ -112,49 +112,8 @@ class PuterFSProvider extends putility.AdvancedBase { } async move ({ context, node, new_parent, new_name, metadata }) { - - const old_path = await node.get('path'); - const new_path = path.join(await new_parent.get('path'), new_name); - - const svc_fsEntry = this.#services.get('fsEntryService'); - const op_update = await svc_fsEntry.update(node.uid, { - ...( - await node.get('parent_uid') !== await new_parent.get('uid') - ? { parent_uid: await new_parent.get('uid') } - : {} - ), - path: new_path, - name: new_name, - ...(metadata ? { metadata } : {}), - }); - - node.entry.name = new_name; - node.entry.path = new_path; - - // NOTE: this is a safeguard passed to update_child_paths to isolate - // changes to the owner's directory tree, ut this may need to be - // removed in the future. - const user_id = await node.get('user_id'); - - await op_update.awaitDone(); - - const svc_fs = this.#services.get('filesystem'); - await svc_fs.update_child_paths(old_path, node.entry.path, user_id); - - const svc_event = this.#services.get('event'); - - const promises = []; - promises.push(svc_event.emit('fs.move.file', { - context, - moved: node, - old_path, - })); - promises.push(svc_event.emit('fs.rename', { - uid: await node.get('uid'), - new_name, - })); - - return node; + console.error('This .move should not be called!'); + throw new Error('This .move should not be called!'); } async copy_tree ({ context, node, options = {} }) {