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])
| 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 | /// |
nothing calls this directly
no test coverage detected