25 lines
749 B
JavaScript
25 lines
749 B
JavaScript
|
const { Errors } = require('../../shared')
|
||
|
const { NodeDescriptorType } = require('../../enum')
|
||
|
|
||
|
module.exports = exports = async (message, di) => {
|
||
|
const Node = di.models.get('fs:Node')
|
||
|
const { path } = message.data()
|
||
|
|
||
|
const node = await Node.get_path(path, message.socket.session.overlay_name || 'mainline')
|
||
|
if ( !node ) {
|
||
|
return message.send_response(
|
||
|
message.fresh().error(Errors.NodeDoesNotExist)
|
||
|
)
|
||
|
}
|
||
|
|
||
|
if ( node.descriptor_type !== NodeDescriptorType.Symlink ) {
|
||
|
return message.send_response(
|
||
|
message.fresh().error(Errors.NodeAlreadyExists)
|
||
|
)
|
||
|
}
|
||
|
|
||
|
message.send_response(
|
||
|
message.fresh().data({ node: node.to_api(), link: node.symlink_path })
|
||
|
)
|
||
|
}
|