Skip to content

feat(#61): confirm before restore overwrites or deletes files - #92

Merged
kavix merged 2 commits into
kavix:mainfrom
vsolano9:fix/61-restore-confirmation
Aug 10, 2026
Merged

feat(#61): confirm before restore overwrites or deletes files#92
kavix merged 2 commits into
kavix:mainfrom
vsolano9:fix/61-restore-confirmation

Conversation

@vsolano9

@vsolano9 vsolano9 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Closes #61.

eko restore could overwrite modified files and remove files absent from the selected snapshot without confirmation. That made a correct snapshot ID insufficient protection against losing unsaved work.

Behavior

  • Interactive restore now previews the exact working-tree paths it will overwrite or delete and proceeds only on explicit y / yes.
  • Unchanged files and files that the snapshot will only create are omitted from the warning.
  • Bare Enter, EOF, or any other answer cancels without restoring.
  • --yes / -y is the explicit non-interactive path.
  • A pipe or regular file on stdin without --yes returns an error instead of guessing or hanging. /dev/null safely reaches EOF and cancels.
  • Snapshot resolution still happens before the prompt, so an unknown ID cannot prompt or mutate the working tree.

The branch is rebased onto the current content-addressed snapshot implementation (93a5041). snapshot.PendingRestoreChanges and the restore path share the same workspace scan and content comparison, so the preview follows the same manifest/hash decisions used to restore. Legacy snapshots retain their existing top-level removal preview.

Validation

  • go test ./...
  • go vet ./...
  • go build ./...
  • git diff --check

The restore tests cover decline, bare Enter, EOF, confirmation, exact destructive-path preview, non-TTY refusal, --yes, unknown IDs, and unchanged-file omission. The preview test was observed red after the upstream CAS rebase (stable.txt was incorrectly listed) before the shared content comparison was added.

Scope

This does not auto-create a pre-restore snapshot. That would introduce separate retention and naming behavior and is better handled independently.

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

@vsolano9 is attempting to deploy a commit to the Kavindu's projects Team on Vercel.

A member of the Team first needs to authorize it.

eko restore deleted every non-ignored top-level entry with no confirmation, so
running it with unsaved work permanently discarded that work even when the
snapshot id was the intended one.

restore now lists exactly what it will delete and requires an explicit y.
Anything else, including a bare Enter and EOF, cancels without touching disk.
--yes/-y skips the prompt for scripting.

When stdin is not a terminal and --yes was not passed, restore fails instead of
guessing: assuming yes would delete a script's working directory that never
opted in, and blocking on a read would hang CI until it times out.

The prompt's list comes from snapshot.PendingRemovals, which RestoreSnapshot
also uses to build its delete list, so what the user is shown and what is
deleted cannot drift apart.
@vsolano9
vsolano9 force-pushed the fix/61-restore-confirmation branch from 6cc7bc1 to 383dd95 Compare August 9, 2026 05:31
@vsolano9 vsolano9 changed the title feat(#61): confirm before restore deletes the working directory feat(#61): confirm before restore overwrites or deletes files Aug 9, 2026
@kavix
kavix merged commit f32d997 into kavix:main Aug 10, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eko restore has no confirmation prompt before destructively deleting the working directory

2 participants