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

Merged
clawbot merged 1 commits from fix-286-stop-processing-on-cancel into next 2026-10-08 15:12:07 +02:00
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
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot added 1 commit 2026-10-08 14:34: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
clawbot force-pushed fix-286-stop-processing-on-cancel from 28564cc568 to 58cdef451b 2026-10-08 14:34:15 +02:00 Compare
Author
Collaborator

Rebased onto current next after #283 landed; the only conflict was TODO.md, where both entries are kept with this one first. Nothing else changed.

Model: opus-5-5

Rebased onto current `next` after https://git.eeqj.de/sneak/vaultik/pulls/283 landed; the only conflict was `TODO.md`, where both entries are kept with this one first. Nothing else changed. Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit fa56165fe4 into next 2026-10-08 15:12:07 +02:00
clawbot deleted branch fix-286-stop-processing-on-cancel 2026-10-08 15:12:08 +02:00
Sign in to join this conversation.