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.
videl/src/delete.rs

47 lines
1.3 KiB

//! Handle deletion
//!
//! # Handling paths
//! Deletion of single files is trivial, deletion of directories is not as trivial.
//! Other types of filesystem object are ignored.
//!
//! ## Directories
//! With directories the deletion processes all files containing recursively.
//! See `restore` for restoration of directories
use super::*;
use std::{
path::{
Path,
},
};
/// Process a single file.
///
/// `path` is known to be a file at this point.
async fn process_single(state: Arc<state::State>, path: &Path) -> eyre::Result<()>
{
let _g = state.lock().await;
debug!("{:?} Processing", path);
Ok(())
}
/// Process this path
///
/// This will not return until all its children finish too (if any)
pub async fn process(state: Arc<state::State>, path: impl AsRef<Path>) -> eyre::Result<()>
{
let path = path.as_ref();
if path.is_dir() {
trace!("{:?} Spawning children", path);
//TODO! Walk dir tree
todo!()
} else if path.is_file() {
process_single(state, path).await
.wrap_err(eyre!("Processing file failed"))
.with_section(|| format!("{:?}", path).header("Path was"))
} else {
error!("{:?} is not a recognised FS object", path);
return Err(eyre!("Unsupported FS object"))
.with_section(|| format!("{:?}", path).header("Path was"))
}
}