Recursively add all files under a directory to Atomic tracking.
(repo: &Repository, dir: &std::path::Path)
| 643 | |
| 644 | /// Recursively add all files under a directory to Atomic tracking. |
| 645 | fn add_vault_files_recursive(repo: &Repository, dir: &std::path::Path) -> CliResult<()> { |
| 646 | let entries = std::fs::read_dir(dir).map_err(CliError::Io)?; |
| 647 | for entry in entries { |
| 648 | let entry = entry.map_err(CliError::Io)?; |
| 649 | let path = entry.path(); |
| 650 | if path.is_dir() { |
| 651 | add_vault_files_recursive(repo, &path)?; |
| 652 | } else if path.is_file() { |
| 653 | if let Ok(rel) = path.strip_prefix(repo.root()) { |
| 654 | let rel_str = rel.to_string_lossy().replace('\\', "/"); |
| 655 | let _ = repo.add(&rel_str, atomic_repository::TrackingOptions::default()); |
| 656 | } |
| 657 | } |
| 658 | } |
| 659 | Ok(()) |
| 660 | } |
| 661 | |
| 662 | // Tests |
| 663 |