Mountain/RPC/CocoonService/FileSystem/
CreateDirectory.rs1
2use tonic::{Response, Status};
5
6use crate::{
7 RPC::CocoonService::CocoonServiceImpl,
8 Vine::Generated::{CreateDirectoryRequest, Empty},
9 dev_log,
10};
11
12pub async fn Fn(_Service:&CocoonServiceImpl, Request:CreateDirectoryRequest) -> Result<Response<Empty>, Status> {
13 let Path = CocoonServiceImpl::UriToPath(Request.uri.as_ref())
14 .ok_or_else(|| Status::invalid_argument("create_directory: missing URI"))?;
15
16 dev_log!("cocoon", "[CocoonService] create_directory: {:?}", Path);
17
18 tokio::fs::create_dir_all(&Path)
19 .await
20 .map_err(|Error| Status::internal(format!("create_directory: {}: {}", Path.display(), Error)))?;
21
22 Ok(Response::new(Empty {}))
23}