35 lines
931 B
JavaScript
35 lines
931 B
JavaScript
|
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 { path, mode } = message.data()
|
||
|
|
||
|
if ( !path ) {
|
||
|
return message.send_response(
|
||
|
message.fresh().error(Errors.NodeDoesNotExist)
|
||
|
)
|
||
|
}
|
||
|
|
||
|
if ( path === '/' ) {
|
||
|
return message.send_response(
|
||
|
message.fresh().error(Errors.NodePermissionFail)
|
||
|
)
|
||
|
}
|
||
|
|
||
|
const node = await Node.get_path(path, message.socket.session.overlay_name || 'mainline')
|
||
|
if ( !node ) {
|
||
|
return message.send_response(
|
||
|
message.fresh().error(Errors.NodeDoesNotExist)
|
||
|
)
|
||
|
}
|
||
|
|
||
|
node.mode = mode
|
||
|
await node.save()
|
||
|
|
||
|
message.send_response(
|
||
|
message.fresh().data({ node: node.to_api() })
|
||
|
)
|
||
|
}
|