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

Method add_batch

atomic-repository/src/repository/tracking.rs:132–159  ·  view source on GitHub ↗

Add multiple files to tracking in a single write transaction. This is much faster than calling `add()` in a loop because it avoids opening a separate write transaction (and fsync) for each file. For git import of a commit adding 20 files, this reduces from 20 fsyncs to 1. # Arguments `paths` - Paths to add (relative to repository root) # Returns Number of files actually added (skips already-t

(&self, paths: &[&str])

Source from the content-addressed store, hash-verified

130 ///
131 /// Number of files actually added (skips already-tracked files).
132 pub fn add_batch(&self, paths: &[&str]) -> Result<usize, RepositoryError> {
133 if paths.is_empty() {
134 return Ok(0);
135 }
136
137 let mut txn = self
138 .pristine
139 .write_txn()
140 .map_err(|e| RepositoryError::Database(e.to_string()))?;
141
142 let mut count = 0usize;
143 for path in paths {
144 let normalized = normalize_path(Path::new(path));
145 if is_tracked(&txn, &normalized)
146 .map_err(|e| RepositoryError::Database(e.to_string()))?
147 {
148 continue;
149 }
150 add_to_tree(&mut txn, &normalized, false)
151 .map_err(|e| RepositoryError::Database(e.to_string()))?;
152 count += 1;
153 }
154
155 txn.commit()
156 .map_err(|e| RepositoryError::Database(e.to_string()))?;
157
158 Ok(count)
159 }
160
161 /// Remove multiple files from tracking in a single write transaction.
162 ///

Callers 2

write_commitMethod · 0.80
record_turnFunction · 0.80

Calls 6

is_trackedFunction · 0.85
add_to_treeFunction · 0.85
write_txnMethod · 0.80
commitMethod · 0.80
normalize_pathFunction · 0.50
is_emptyMethod · 0.45

Tested by

no test coverage detected