Mountain/RPC/CocoonService/GenericRequest/FileSystem/
Delete.rs1#![allow(unused_variables, dead_code, unused_imports)]
2
3use serde_json::Value;
4use tonic::Response;
5
6use crate::Vine::Generated::GenericResponse;
7
8pub async fn Fn(RequestId:u64, Params:Value) -> Response<GenericResponse> {
9 let Path = Params
10 .as_str()
11 .or_else(|| Params.get("path").and_then(|V| V.as_str()))
12 .unwrap_or("");
13
14 let Result = if std::path::Path::new(Path).is_dir() {
15 tokio::fs::remove_dir_all(Path).await
16 } else {
17 tokio::fs::remove_file(Path).await
18 };
19
20 match Result {
21 Ok(()) => super::OkResponse(RequestId, &Value::Null),
22
23 Err(Error) => super::ErrResponse(RequestId, -32000, format!("fs.delete: {}", Error)),
24 }
25}