Skip to content

Commit

Permalink
filestore: Add remove_dir_all_where method
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Jun 8, 2023
1 parent fd6a020 commit 676ed80
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/store/filestore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize>;
fn remove_dir_all_where(
&mut self,
path: &Path,
location: Location,
predicate: impl Fn(&DirEntry) -> bool,
) -> Result<usize>;
fn locate_file(
&mut self,
location: Location,
Expand Down Expand Up @@ -394,6 +400,17 @@ impl<S: Store> Filestore for ClientFilestore<S> {
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<usize> {
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,
Expand Down

0 comments on commit 676ed80

Please sign in to comment.