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

Method remove_path

atomic-repository/src/repository/switch.rs:411–445  ·  view source on GitHub ↗
(&mut self, path: &str)

Source from the content-addressed store, hash-verified

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
448impl Repository {

Callers 1

remove_absent_entriesMethod · 0.45

Calls 9

path_beneath_symlinkFunction · 0.85
as_refMethod · 0.80
is_noneMethod · 0.80
execute_absenceMethod · 0.80
containsMethod · 0.45
rootMethod · 0.45
kindMethod · 0.45
recordMethod · 0.45

Tested by

no test coverage detected