From 676ed8021e8fbd8efafe291c57466708f3d56fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Tue, 9 May 2023 10:17:26 +0200 Subject: [PATCH] filestore: Add remove_dir_all_where method --- src/store/filestore.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/store/filestore.rs b/src/store/filestore.rs index 912ced5612e..c093f3b5086 100644 --- a/src/store/filestore.rs +++ b/src/store/filestore.rs @@ -83,6 +83,12 @@ pub trait Filestore { fn remove_file(&mut self, path: &Path, location: Location) -> Result<()>; fn remove_dir(&mut self, path: &Path, location: Location) -> Result<()>; fn remove_dir_all(&mut self, path: &Path, location: Location) -> Result; + fn remove_dir_all_where( + &mut self, + path: &Path, + location: Location, + predicate: impl Fn(&DirEntry) -> bool, + ) -> Result; fn locate_file( &mut self, location: Location, @@ -394,6 +400,17 @@ impl Filestore for ClientFilestore { store::remove_dir_all_where(self.store, location, &path, |_| true) .map_err(|_| Error::InternalError) } + fn remove_dir_all_where( + &mut self, + path: &Path, + location: Location, + predicate: impl Fn(&DirEntry) -> bool, + ) -> Result { + let path = self.actual_path(path)?; + + store::remove_dir_all_where(self.store, location, &path, predicate) + .map_err(|_| Error::InternalError) + } fn read_dir_first( &mut self,