Skip to main content

rollback

Function rollback 

Source
pub fn rollback(paths: &BackupPaths) -> Result<()>
Expand description

Roll back a partially-applied rotation. Used when the in-memory mutation step fails (or its post-write parse fails). Restores the on-disk state to what it was before rotate ran:

  • The workload itself wasn’t touched by rotate (we copied, didn’t move), so it’s already correct.
  • <workload>.bak was overwritten by the copy from the workload — that’s a no-op semantically (the bak now matches the workload, same as it would after a clean commit on the same content). To preserve the “.bak holds the pre-edit content” invariant strictly, we restore the previous .bak from .bak.prev (which was the prior pre-edit content before the rotate).
  • <workload>.bak.prev is restored to whatever it was before the rotate — but we don’t have that; the rotation overwrote it. Best effort: leave the current .bak.prev as the recovery point.

In short: roll back the bak↔bak.prev swap so the invariant “.bak == content prior to the most recent successful edit” holds.