Find the directory for an identity by ID.
(&self, id: &IdentityId)
| 957 | |
| 958 | /// Find the directory for an identity by ID. |
| 959 | fn find_identity_dir(&self, id: &IdentityId) -> Result<PathBuf, IdentityError> { |
| 960 | let id_suffix = id.short(); |
| 961 | |
| 962 | for entry in fs::read_dir(&self.root)? { |
| 963 | let entry = entry?; |
| 964 | let path = entry.path(); |
| 965 | |
| 966 | if path.is_dir() { |
| 967 | if let Some(name) = path.file_name().and_then(|n| n.to_str()) { |
| 968 | if name.ends_with(&id_suffix) { |
| 969 | return Ok(path); |
| 970 | } |
| 971 | } |
| 972 | } |
| 973 | } |
| 974 | |
| 975 | Err(IdentityError::NotFound { |
| 976 | name: id.to_base32(), |
| 977 | }) |
| 978 | } |
| 979 | |
| 980 | /// Save the store configuration. |
| 981 | fn save_config(&self) -> Result<(), IdentityError> { |