You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
976 B

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()
console.log('symlink node', node)
message.send_response(
message.fresh().data({ node: node.to_api() })
)
}