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

Method remove_batch

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

Remove multiple files from tracking in a single write transaction. This is much faster than calling `remove()` in a loop because it avoids a separate write transaction (and fsync) for each file. # Arguments `paths` - Paths to remove (relative to repository root) # Returns Number of files actually removed.

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

Source from the content-addressed store, hash-verified

171 ///
172 /// Number of files actually removed.
173 pub fn remove_batch(&self, paths: &[&str]) -> Result<usize, RepositoryError> {
174 if paths.is_empty() {
175 return Ok(0);
176 }
177
178 let mut txn = self
179 .pristine
180 .write_txn()
181 .map_err(|e| RepositoryError::Database(e.to_string()))?;
182
183 let mut count = 0usize;
184 for path in paths {
185 let normalized = normalize_path(Path::new(path));
186 if remove_from_tree(&mut txn, &normalized)
187 .map_err(|e| RepositoryError::Database(e.to_string()))?
188 .is_some()
189 {
190 count += 1;
191 }
192 }
193
194 txn.commit()
195 .map_err(|e| RepositoryError::Database(e.to_string()))?;
196
197 Ok(count)
198 }
199
200 /// Add an empty directory to tracking explicitly.
201 ///

Callers

nothing calls this directly

Calls 5

remove_from_treeFunction · 0.85
write_txnMethod · 0.80
commitMethod · 0.80
normalize_pathFunction · 0.50
is_emptyMethod · 0.45

Tested by

no test coverage detected