(&self, operation: &Operation, root: &Path)
| 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( |
no test coverage detected