Load identity info from a directory matching the given ID.
(identities_dir: &Path, id_base32: &str)
| 284 | |
| 285 | /// Load identity info from a directory matching the given ID. |
| 286 | fn load_identity_by_id(identities_dir: &Path, id_base32: &str) -> Option<UserIdentityInfo> { |
| 287 | // The ID might be used directly as part of the directory name |
| 288 | let entries = std::fs::read_dir(identities_dir).ok()?; |
| 289 | |
| 290 | for entry in entries.flatten() { |
| 291 | let _dir_name = entry.file_name().to_string_lossy().to_string(); |
| 292 | |
| 293 | // Skip non-directories and config files |
| 294 | if !entry.path().is_dir() { |
| 295 | continue; |
| 296 | } |
| 297 | |
| 298 | // Check if this directory's identity.toml contains the matching ID |
| 299 | let identity_path = entry.path().join("identity.toml"); |
| 300 | if let Ok(content) = std::fs::read_to_string(&identity_path) { |
| 301 | if content.contains(id_base32) { |
| 302 | return parse_identity_toml(&content); |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | None |
| 307 | } |
| 308 | |
| 309 | /// Scan all identity directories and try to find one matching the ID. |
| 310 | fn load_identity_by_scanning(identities_dir: &Path, id_base32: &str) -> Option<UserIdentityInfo> { |
no test coverage detected