use crate::Operation::DeleteFiles;
#[cfg(feature = "r2")]
use crate::R2Path;
use crate::Reason::UnknownFileSystem;
use crate::{Error, FolderPath, LocalPath};
impl FolderPath {
pub fn delete_files(&self) -> Result<(), Error> {
if let Some(path) = LocalPath::new(self.path()) {
return path.delete_files();
}
#[cfg(feature = "r2")]
if let Some(path) = R2Path::new(self.path()) {
return path.delete_files();
}
Err(Error::new(self.clone(), DeleteFiles, UnknownFileSystem))
}
}
#[cfg(test)]
mod tests {
use crate::{Error, FolderPath, Operation, Reason, StoragePath};
#[test]
fn other_hosts_path_is_unknown_file_system() {
let path: &str = if cfg!(windows) {
"/folder/"
} else {
"C:\\folder\\"
};
let folder: FolderPath = StoragePath::parse(path).unwrap().to_folder().unwrap();
let error: Error = folder.delete_files().unwrap_err();
assert_eq!(error.operation(), Operation::DeleteFiles);
assert_eq!(error.reason(), Reason::UnknownFileSystem);
}
}