//! 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, 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, path: impl AsRef) -> 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")) } }