(&mut self, path: &str)
| 409 | } |
| 410 | |
| 411 | fn remove_path(&mut self, path: &str) -> Result<bool, RepositoryError> { |
| 412 | // The materializer also discovers historical FILE_INDEX rows. A path |
| 413 | // absent from both the source's live projection and the target's |
| 414 | // explicit deletions is now untracked, not a switch removal. Leave its |
| 415 | // bytes alone; the caller may retire the stale index row. For paths in |
| 416 | // the planned scope the normal lease checks below remain mandatory. |
| 417 | if self |
| 418 | .switch_removal_scope |
| 419 | .as_ref() |
| 420 | .is_some_and(|paths| !paths.contains(path)) |
| 421 | { |
| 422 | return Ok(false); |
| 423 | } |
| 424 | if self |
| 425 | .effect_for_expected_new(path, |value| *value == EffectValue::Absent) |
| 426 | .is_none() |
| 427 | { |
| 428 | // Nothing Atomic wrote can sit beneath a symlink (the effect |
| 429 | // guard never writes through one), so a path whose ancestor is a |
| 430 | // symlink on disk has nothing to remove even though the link's |
| 431 | // target makes it resolve. |
| 432 | if path_beneath_symlink(self.repository.root(), path) { |
| 433 | return Ok(false); |
| 434 | } |
| 435 | return match std::fs::symlink_metadata(self.repository.root().join(path)) { |
| 436 | Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(false), |
| 437 | Ok(_) => Err(RepositoryError::InvalidOperation { |
| 438 | message: format!("switch operation omitted removal lease for '{path}'"), |
| 439 | }), |
| 440 | Err(error) => Err(RepositoryError::Io(error)), |
| 441 | }; |
| 442 | } |
| 443 | let pending = self.execute_absence(path)?; |
| 444 | self.record(pending) |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | impl Repository { |
no test coverage detected