dev(puterfs): move 'move' to extension

This commit is contained in:
KernelDeimos
2025-11-06 17:14:09 -05:00
committed by Eric Dubé
parent 5d1d5125ab
commit 7988dc9adf
2 changed files with 43 additions and 43 deletions
+41
View File
@@ -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') ) {
@@ -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 = {} }) {