T-2UB1-backup-undo-recreated-file
State: planning/draft · Impact: low · Complexity: small
Restoring a replaced file offers Undo. Restoring a deleted file does not, so a user who brings back the wrong file has to delete it by hand. Both restores should be undoable the same way.
useBackupRestore.ts shows Undo only when result.replaced is true. Undo restores the path from
the safety snapshot. When the restore recreated a deleted file, the path is absent from the safety
snapshot, and restore_file refuses a path that does not exist at the given sha (T-7PT3 AC-4). So
there is nothing for Undo to call.
Proposed
Section titled “Proposed”- The backend can undo a recreate. The undo request carries both shas from
BackupRestoreResult:safety_sha, where the path is absent, andrestored_from, which holds the content the restore wrote. Undo removes the path. It takes its own safety snapshot first, as every restore does, so the recreated file stays recoverable. - Before removing anything, the backend compares the file on disk with
<restored_from>:<path>. If the user edited it since, the undo is refused with a clear message instead of deleting their edit. - The toast offers Undo for both kinds of restore. The undo toast for a recreate says the file was removed again and names the snapshot that holds it.
Approach
Section titled “Approach”- Decide the API shape: whichever carries both
safety_shaandrestored_from. That is either an optionalexpected_fromfield onBackupRestoreRequestthat lets “absent at sha” mean remove, or a separate undo endpoint. Prefer the field if it keeps one code path inrestore.rs. - Implement the removal behind the same job key and safety snapshot, with the content check.
- Show Undo for recreated files in
useBackupRestore.tsand update its tests and the e2e spec.
| Area | Note |
|---|---|
solutions/determined/crates/determined-backup/src/restore.rs | Remove-on-undo with a content check |
solutions/determined/crates/determined-core/src/wire/ | Request or result change |
solutions/determined/experiences/backup/app/composables/useBackupRestore.ts | Undo for recreated files |
solutions/determined/tests/ui/backup/ | Extend the restore-deleted step with Undo |
Acceptance criteria
Section titled “Acceptance criteria”- AC-1: After restoring a deleted file, the toast offers Undo, and Undo removes the file.
- AC-2: The recreated content is in the snapshot taken before the undo.
- AC-3: If the file changed after the restore, Undo is refused and the file is left as is.
- AC-4: Undo for a replaced file behaves as before.
Out of scope
Section titled “Out of scope”- Undo for folder restores, which do not exist yet.
Dependencies
Section titled “Dependencies”- none