Stop a cancelled backup at once under --skip-errors #287

Open
clawbot wants to merge 1 commits from fix-286-stop-processing-on-cancel into next
Collaborator

Fixes #286.

After Ctrl-C or SIGTERM, phase 2 of a --skip-errors backup treated the cancellation error from each remaining file like an unreadable file: it opened the file, printed an error line, counted it as failed and moved on to the next.

Two changes in internal/snapshot/scanner.go:

  • processPhase checks for cancellation before each file, as the scan phase already does.
  • processFileWithErrorHandling stops the run on any file error once the run is cancelled, ahead of the --skip-errors branch.

The second check covers the file being read when the cancel lands. The first covers an empty file, which has no chunks: nothing reads the context while it is backed up, so without the loop check the run would still open the next file before noticing.

The new test cancels a run in both places and checks that the scan returns context.Canceled, opens no file after the cancel and prints no error line. runSkipErrorScan now takes the context, so its other callers pass context.Background().

What the diff does not show: on next the cancelled scan returned no error at all after skipping every remaining file. Only the command layer, which watches for the signal itself, reported the run as interrupted.

Judgement call: when a file fails for its own reason after the run is cancelled, the run returns that file's error rather than the bare cancellation error. It stops either way.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/vaultik/issues/286. After Ctrl-C or SIGTERM, phase 2 of a `--skip-errors` backup treated the cancellation error from each remaining file like an unreadable file: it opened the file, printed an error line, counted it as failed and moved on to the next. Two changes in `internal/snapshot/scanner.go`: - `processPhase` checks for cancellation before each file, as the scan phase already does. - `processFileWithErrorHandling` stops the run on any file error once the run is cancelled, ahead of the `--skip-errors` branch. The second check covers the file being read when the cancel lands. The first covers an empty file, which has no chunks: nothing reads the context while it is backed up, so without the loop check the run would still open the next file before noticing. The new test cancels a run in both places and checks that the scan returns `context.Canceled`, opens no file after the cancel and prints no error line. `runSkipErrorScan` now takes the context, so its other callers pass `context.Background()`. What the diff does not show: on `next` the cancelled scan returned no error at all after skipping every remaining file. Only the command layer, which watches for the signal itself, reported the run as interrupted. Judgement call: when a file fails for its own reason after the run is cancelled, the run returns that file's error rather than the bare cancellation error. It stops either way. Model: opus-5-5
clawbot added the needs-review label 2026-10-08 13:38:15 +02:00
clawbot self-assigned this 2026-10-08 13:38:15 +02:00
clawbot added 1 commit 2026-10-08 13:38:15 +02:00
After Ctrl-C or SIGTERM, phase 2 of a --skip-errors backup treated the
cancellation error from each remaining file like an unreadable file: it
opened the file, printed an error line, counted it as failed and moved
on to the next. The processing loop now checks for cancellation before
each file, and an error from a file once the run is cancelled stops the
run instead of being skipped. The loop check is what stops a run
cancelled while an empty file is open, since an empty file has no
chunks and nothing reads the context while it is backed up.

The --skip-errors test helper now takes the scan's context.

Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
Some checks are pending
check / check (push) Waiting to run
This pull request has changes conflicting with the target branch.
  • TODO.md
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix-286-stop-processing-on-cancel:fix-286-stop-processing-on-cancel
git checkout fix-286-stop-processing-on-cancel
Sign in to join this conversation.