mirror of
https://github.com/HeyPuter/puter.git
synced 2026-01-07 13:40:51 -06:00
dev: ll_move -> provider.move
This commit is contained in:
@@ -24,10 +24,8 @@ class LLMove extends LLFilesystemOperation {
|
||||
}
|
||||
|
||||
async _run () {
|
||||
const { _path } = this.modules;
|
||||
const { context } = this;
|
||||
const { source, parent, user, actor, target_name, metadata } = this.values;
|
||||
const svc = context.get('services');
|
||||
const { source, parent, actor, target_name, metadata } = this.values;
|
||||
|
||||
// Access Control
|
||||
{
|
||||
@@ -45,36 +43,13 @@ class LLMove extends LLFilesystemOperation {
|
||||
}
|
||||
}
|
||||
|
||||
const old_path = await source.get('path');
|
||||
|
||||
const svc_fsEntry = svc.get('fsEntryService');
|
||||
const op_update = await svc_fsEntry.update(source.uid, {
|
||||
...(
|
||||
await source.get('parent_uid') !== await parent.get('uid')
|
||||
? { parent_uid: await parent.get('uid') }
|
||||
: {}
|
||||
),
|
||||
path: _path.join(await parent.get('path'), target_name),
|
||||
name: target_name,
|
||||
...(metadata ? { metadata } : {}),
|
||||
});
|
||||
|
||||
source.entry.name = target_name;
|
||||
source.entry.path = _path.join(await parent.get('path'), target_name);
|
||||
|
||||
await op_update.awaitDone();
|
||||
|
||||
const svc_fs = svc.get('filesystem');
|
||||
await svc_fs.update_child_paths(old_path, source.entry.path, user.id);
|
||||
|
||||
const svc_event = svc.get('event');
|
||||
|
||||
await svc_event.emit('fs.move.file', {
|
||||
await source.provider.move({
|
||||
context: this.context,
|
||||
moved: source,
|
||||
old_path,
|
||||
node: source,
|
||||
new_parent: parent,
|
||||
new_name: target_name,
|
||||
metadata,
|
||||
});
|
||||
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +152,49 @@ class PuterFSProvider extends putility.AdvancedBase {
|
||||
return child_uuids;
|
||||
}
|
||||
|
||||
async move ({ context, node, new_parent, new_name, metadata }) {
|
||||
const { _path } = this.modules;
|
||||
|
||||
const services = context.get('services');
|
||||
const old_path = await node.get('path');
|
||||
const new_path = _path.join(await new_parent.get('path'), new_name);
|
||||
|
||||
const svc_fsEntry = 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 = services.get('filesystem');
|
||||
await svc_fs.update_child_paths(old_path, node.entry.path, user_id);
|
||||
|
||||
const svc_event = services.get('event');
|
||||
|
||||
await svc_event.emit('fs.move.file', {
|
||||
context,
|
||||
moved: node,
|
||||
old_path,
|
||||
});
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
async copy_tree ({ context, source, parent, target_name }) {
|
||||
return await this.copy_tree_(
|
||||
{ context, source, parent, target_name });
|
||||
|
||||
Reference in New Issue
Block a user