MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / find_identity_dir

Method find_identity_dir

atomic-identity/src/store.rs:959–978  ·  view source on GitHub ↗

Find the directory for an identity by ID.

(&self, id: &IdentityId)

Source from the content-addressed store, hash-verified

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> {

Calls 5

is_dirMethod · 0.80
shortMethod · 0.45
pathMethod · 0.45
file_nameMethod · 0.45
to_base32Method · 0.45