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

Method verify_backup

atomic-repository/src/repository/operation.rs:2954–3009  ·  view source on GitHub ↗
(&self, operation: &Operation, root: &Path)

Source from the content-addressed store, hash-verified

2952 }
2953
2954 fn verify_backup(&self, operation: &Operation, root: &Path) -> Result<(), RepositoryError> {
2955 let marker = fs::read(root.join(BACKUP_COMPLETE))?;
2956 if marker != BACKUP_VERSION {
2957 return Err(RepositoryError::InvalidOperation {
2958 message: format!(
2959 "operation recovery backup {} has an invalid complete marker",
2960 root.display()
2961 ),
2962 });
2963 }
2964 let mut verified_targets = Vec::new();
2965 for effect in &operation.payload().delta.effects {
2966 if !is_filesystem_effect(&effect.target) || verified_targets.contains(&effect.target) {
2967 continue;
2968 }
2969 verified_targets.push(effect.target.clone());
2970 let entry = backup_entry_path(root, effect.ordinal);
2971 match &effect.expected_old {
2972 EffectValue::Absent => {
2973 if fs::read(entry.join(BACKUP_ABSENT))? != BACKUP_VERSION {
2974 return Err(RepositoryError::InvalidOperation {
2975 message: format!(
2976 "operation {} effect {} has an invalid absent backup",
2977 operation.id(),
2978 effect.ordinal
2979 ),
2980 });
2981 }
2982 }
2983 EffectValue::File(_) => {
2984 let observed = observe_path(
2985 &entry.join(BACKUP_VALUE),
2986 is_recursive_filesystem_target(&effect.target),
2987 )?;
2988 if observed != effect.expected_old {
2989 return Err(RepositoryError::InvalidOperation {
2990 message: format!(
2991 "operation {} effect {} backup no longer matches expected-old",
2992 operation.id(),
2993 effect.ordinal
2994 ),
2995 });
2996 }
2997 }
2998 value => {
2999 return Err(RepositoryError::InvalidOperation {
3000 message: format!(
3001 "filesystem effect {} expected-old must be Absent or File, found {value:?}",
3002 effect.ordinal
3003 ),
3004 })
3005 }
3006 }
3007 }
3008 Ok(())
3009 }
3010
3011 fn replay_filesystem_recovery(

Callers 2

Calls 9

is_filesystem_effectFunction · 0.85
backup_entry_pathFunction · 0.85
observe_pathFunction · 0.70
readFunction · 0.50
payloadMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected