Recursively add all files under a directory to Atomic tracking.
(repo: &Repository, dir: &std::path::Path)
| 752 | |
| 753 | /// Recursively add all files under a directory to Atomic tracking. |
| 754 | fn add_vault_files_recursive(repo: &Repository, dir: &std::path::Path) -> CliResult<()> { |
| 755 | let working_copy = repo |
| 756 | .require_working_copy_id() |
| 757 | .map_err(CliError::Repository)?; |
| 758 | let entries = std::fs::read_dir(dir).map_err(CliError::Io)?; |
| 759 | for entry in entries { |
| 760 | let entry = entry.map_err(CliError::Io)?; |
| 761 | let path = entry.path(); |
| 762 | if path.is_dir() { |
| 763 | add_vault_files_recursive(repo, &path)?; |
| 764 | } else if path.is_file() { |
| 765 | if let Ok(rel) = path.strip_prefix(repo.root()) { |
| 766 | let rel_str = rel.to_string_lossy().replace('\\', "/"); |
| 767 | let _ = repo.add( |
| 768 | working_copy, |
| 769 | &rel_str, |
| 770 | atomic_repository::TrackingOptions::default(), |
| 771 | ); |
| 772 | } |
| 773 | } |
| 774 | } |
| 775 | Ok(()) |
| 776 | } |
| 777 | |
| 778 | // Tests |
| 779 |
no test coverage detected