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

Function add_dir_recursive

atomic-cli/src/commands/git/import.rs:2099–2121  ·  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

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

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