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