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
877 B

const { Errors } = require('../../shared')
const { NodeDescriptorType } = require('../../enum')
// TODO should this return size info for the temp write file?
module.exports = exports = async (message, di) => {
const Node = di.models.get('fs:Node')
const { descriptor } = message.data()
const node_uuid = message.socket.session.file_descriptors?.[descriptor]
if ( !node_uuid ) {
return message.send_response(
message.fresh().error(Errors.NodeDoesNotExist)
)
}
const node = await Node.findOne({
uuid: node_uuid,
deleted: false,
descriptor_type: NodeDescriptorType.File,
})
if ( !node ) {
return message.send_response(
message.fresh().error(Errors.NodeDoesNotExist)
)
}
message.send_response(
message.fresh().data({ node: node.to_api() })
)
}