Skip to content

Commit

Permalink
Fix keystore delete-all counting
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Oct 30, 2023
1 parent 91d501b commit a60b4f5
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/store/keystore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,17 @@ impl<S: Store> Keystore for ClientKeystore<S> {
/// TODO: This uses the predicate "filename.len() >= 4"
/// Be more principled :)
fn delete_all(&self, location: Location) -> Result<usize> {
let path = self.key_directory(key::Secrecy::Secret);
store::remove_dir_all_where(self.store, location, &path, |dir_entry| {
dir_entry.file_name().as_ref().len() >= 4
})?;
let path = self.key_directory(key::Secrecy::Public);
store::remove_dir_all_where(self.store, location, &path, |dir_entry| {
dir_entry.file_name().as_ref().len() >= 4
})
let secret_path = self.key_directory(key::Secrecy::Secret);
let secret_deleted =
store::remove_dir_all_where(self.store, location, &secret_path, |dir_entry| {
dir_entry.file_name().as_ref().len() >= 4
})?;
let public_path = self.key_directory(key::Secrecy::Public);
let public_deleted =
store::remove_dir_all_where(self.store, location, &public_path, |dir_entry| {
dir_entry.file_name().as_ref().len() >= 4
})?;
Ok(secret_deleted + public_deleted)
}

fn load_key(
Expand Down

0 comments on commit a60b4f5

Please sign in to comment.