Add all vault files
(
repo: &Repository,
working_copy: WorkingCopyId,
dir: &std::path::Path,
)
| 2097 | |
| 2098 | // Add all vault files |
| 2099 | fn add_dir_recursive( |
| 2100 | repo: &Repository, |
| 2101 | working_copy: WorkingCopyId, |
| 2102 | dir: &std::path::Path, |
| 2103 | ) { |
| 2104 | if let Ok(entries) = std::fs::read_dir(dir) { |
| 2105 | for entry in entries.flatten() { |
| 2106 | let path = entry.path(); |
| 2107 | if path.is_dir() { |
| 2108 | add_dir_recursive(repo, working_copy, &path); |
| 2109 | } else if path.is_file() { |
| 2110 | if let Ok(rel) = path.strip_prefix(repo.root()) { |
| 2111 | let rel_str = rel.to_string_lossy().replace('\\', "/"); |
| 2112 | let _ = repo.add( |
| 2113 | working_copy, |
| 2114 | &rel_str, |
| 2115 | atomic_repository::TrackingOptions::default(), |
| 2116 | ); |
| 2117 | } |
| 2118 | } |
| 2119 | } |
| 2120 | } |
| 2121 | } |
| 2122 | let vault_dir = repo.vault_dir(); |
| 2123 | if vault_dir.exists() { |
| 2124 | add_dir_recursive(repo, working_copy, &vault_dir); |