Classify and restore every Modified/Deleted path in one pass, returning the outcome for each path so the caller can report them in status order. One projection decides which paths the view still records, and one materialization writes all of them, instead of rendering and materializing file by file. Outcomes match the single-file path: a path the view does not project (or projects as a directory)
(
&self,
repo: &Repository,
working_copy: atomic_core::WorkingCopyId,
view: &str,
paths: &[PathBuf],
)
| 260 | /// would have reported it; if the batched materialization fails, every |
| 261 | /// path falls back to the single-file restore so outcomes stay per file. |
| 262 | fn restore_contents( |
| 263 | &self, |
| 264 | repo: &Repository, |
| 265 | working_copy: atomic_core::WorkingCopyId, |
| 266 | view: &str, |
| 267 | paths: &[PathBuf], |
| 268 | ) -> HashMap<PathBuf, CliResult<RestoreOutcome>> { |
| 269 | let mut outcomes = HashMap::new(); |
| 270 | if paths.is_empty() { |
| 271 | return outcomes; |
| 272 | } |
| 273 | let names: Vec<String> = paths |
| 274 | .iter() |
| 275 | .map(|path| path.to_string_lossy().into_owned()) |
| 276 | .collect(); |
| 277 | let presence = match repo.recorded_presence_on_view(&names, view) { |
| 278 | Ok(presence) => presence, |
| 279 | Err(error) => { |
| 280 | // A view or projection error would fail every single-path read |
| 281 | // the same way; report it per file without re-projecting. |
| 282 | for path in paths { |
| 283 | outcomes.insert( |
| 284 | path.clone(), |
| 285 | Err(CliError::Internal(anyhow::anyhow!( |
| 286 | "Failed to get file content: {}", |
| 287 | error |
| 288 | ))), |
| 289 | ); |
| 290 | } |
| 291 | return outcomes; |
| 292 | } |
| 293 | }; |
| 294 | let mut selected: Vec<(PathBuf, String)> = Vec::new(); |
| 295 | for ((path, name), presence) in paths.iter().zip(&names).zip(presence) { |
| 296 | match presence { |
| 297 | RecordedPresence::Present => selected.push((path.clone(), name.clone())), |
| 298 | RecordedPresence::Absent => { |
| 299 | outcomes.insert(path.clone(), Ok(RestoreOutcome::Skipped)); |
| 300 | } |
| 301 | RecordedPresence::NameConflict { paths, claimants } => { |
| 302 | let error = atomic_repository::name_conflict_error( |
| 303 | &atomic_repository::normalize_path(path), |
| 304 | paths, |
| 305 | claimants, |
| 306 | ); |
| 307 | outcomes.insert( |
| 308 | path.clone(), |
| 309 | Err(CliError::Internal(anyhow::anyhow!( |
| 310 | "Failed to get file content: {}", |
| 311 | error |
| 312 | ))), |
| 313 | ); |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | if selected.is_empty() { |
| 318 | return outcomes; |
| 319 | } |
no test coverage detected