Recursively add all files under a directory to Atomic tracking.
(repo: &Repository, dir: &std::path::Path)
| 630 | |
| 631 | /// Recursively add all files under a directory to Atomic tracking. |
| 632 | fn add_vault_files_recursive(repo: &Repository, dir: &std::path::Path) -> CliResult<()> { |
| 633 | let entries = std::fs::read_dir(dir).map_err(CliError::Io)?; |
| 634 | for entry in entries { |
| 635 | let entry = entry.map_err(CliError::Io)?; |
| 636 | let path = entry.path(); |
| 637 | if path.is_dir() { |
| 638 | add_vault_files_recursive(repo, &path)?; |
| 639 | } else if path.is_file() { |
| 640 | if let Ok(rel) = path.strip_prefix(repo.root()) { |
| 641 | let rel_str = rel.to_string_lossy().replace('\\', "/"); |
| 642 | let _ = repo.add(&rel_str, atomic_repository::TrackingOptions::default()); |
| 643 | } |
| 644 | } |
| 645 | } |
| 646 | Ok(()) |
| 647 | } |
| 648 | |
| 649 | // Tests |
| 650 |