Add support for chmod, descriptor type to mode type mapping
This commit is contained in:
parent
8e57578251
commit
63d105c752
@ -10,4 +10,10 @@ const NodeModeType = {
|
|||||||
Symlink: 40960,
|
Symlink: 40960,
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = exports = { NodeDescriptorType, NodeModeType }
|
const DescriptorTypeXNodeType = {
|
||||||
|
[NodeDescriptorType.File]: NodeModeType.File,
|
||||||
|
[NodeDescriptorType.Directory]: NodeModeType.Directory,
|
||||||
|
[NodeDescriptorType.Symlink]: NodeModeType.Symlink,
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = exports = { NodeDescriptorType, NodeModeType, DescriptorTypeXNodeType }
|
34
app/ws/routes/fs.chmod.js
Normal file
34
app/ws/routes/fs.chmod.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
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() })
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user