const { Errors } = require('../../shared') const { NodeDescriptorType, NodeModeType } = require('../../enum') module.exports = exports = async (message, di) => { const Node = di.models.get('fs:Node') const { source, destination } = message.data() const destination_node = await Node.get_path(destination, message.socket.session.overlay_name || 'mainline') if ( destination_node ) { destination_node.deleted = true await destination_node.save() } const [pied_parent_path, pied_name] = Node.path_parts(destination) const node = new Node({ pied_name, pied_parent_path, overlay_name: message.socket.session.overlay_name || 'mainline', descriptor_type: NodeDescriptorType.Symlink, symlink_path: source, mode: NodeModeType.Symlink, }) await node.save() message.send_response( message.fresh().data({ node: node.to_api() }) ) }