use crate::types::report::ApplyReport;
use crate::types::{Action, Plan};
pub(crate) fn inverse_with_policy(policy: &crate::policy::Policy, report: &ApplyReport) -> Plan {
let mut actions: Vec<Action> = Vec::new();
for act in report.executed.iter().rev() {
match act {
Action::EnsureSymlink { target, .. } => {
actions.push(Action::RestoreFromBackup {
target: target.clone(),
});
}
Action::RestoreFromBackup { target } => {
if policy.apply.capture_restore_snapshot {
actions.push(Action::RestoreFromBackup {
target: target.clone(),
});
} else {
}
}
}
}
Plan { actions }
}