MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / add_dir_recursive

Function add_dir_recursive

atomic-cli/src/commands/git/import.rs:2160–2182  ·  view source on GitHub ↗

Add all vault files

(
                repo: &Repository,
                working_copy: WorkingCopyId,
                dir: &std::path::Path,
            )

Source from the content-addressed store, hash-verified

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);

Callers 1

Calls 6

is_dirMethod · 0.80
pathMethod · 0.45
is_fileMethod · 0.45
rootMethod · 0.45
replaceMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected