Add all vault files
(
repo: &Repository,
working_copy: WorkingCopyId,
dir: &std::path::Path,
)
| 2158 | |
| 2159 | // Add all vault files |
| 2160 | fn add_dir_recursive( |
| 2161 | repo: &Repository, |
| 2162 | working_copy: WorkingCopyId, |
| 2163 | dir: &std::path::Path, |
| 2164 | ) { |
| 2165 | if let Ok(entries) = std::fs::read_dir(dir) { |
| 2166 | for entry in entries.flatten() { |
| 2167 | let path = entry.path(); |
| 2168 | if path.is_dir() { |
| 2169 | add_dir_recursive(repo, working_copy, &path); |
| 2170 | } else if path.is_file() { |
| 2171 | if let Ok(rel) = path.strip_prefix(repo.root()) { |
| 2172 | let rel_str = rel.to_string_lossy().replace('\\', "/"); |
| 2173 | let _ = repo.add( |
| 2174 | working_copy, |
| 2175 | &rel_str, |
| 2176 | atomic_repository::TrackingOptions::default(), |
| 2177 | ); |
| 2178 | } |
| 2179 | } |
| 2180 | } |
| 2181 | } |
| 2182 | } |
| 2183 | let vault_dir = repo.vault_dir(); |
| 2184 | if vault_dir.exists() { |
| 2185 | add_dir_recursive(repo, working_copy, &vault_dir); |