Load identity info from a directory matching the given ID.
(identities_dir: &Path, id_base32: &str)
| 467 | |
| 468 | /// Load identity info from a directory matching the given ID. |
| 469 | fn load_identity_by_id(identities_dir: &Path, id_base32: &str) -> Option<UserIdentityInfo> { |
| 470 | // The ID might be used directly as part of the directory name |
| 471 | let entries = std::fs::read_dir(identities_dir).ok()?; |
| 472 | |
| 473 | for entry in entries.flatten() { |
| 474 | let _dir_name = entry.file_name().to_string_lossy().to_string(); |
| 475 | |
| 476 | // Skip non-directories and config files |
| 477 | if !entry.path().is_dir() { |
| 478 | continue; |
| 479 | } |
| 480 | |
| 481 | // Check if this directory's identity.toml contains the matching ID |
| 482 | let identity_path = entry.path().join("identity.toml"); |
| 483 | if let Ok(content) = std::fs::read_to_string(&identity_path) { |
| 484 | if content.contains(id_base32) { |
| 485 | return parse_identity_toml(&content); |
| 486 | } |
| 487 | } |
| 488 | } |
| 489 | None |
| 490 | } |
| 491 | |
| 492 | /// Scan all identity directories and try to find one matching the ID. |
| 493 | fn load_identity_by_scanning(identities_dir: &Path, id_base32: &str) -> Option<UserIdentityInfo> { |
no test coverage detected