Stop a cancelled backup at once under --skip-errors (closes #286)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
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
This commit is contained in:
@@ -1312,6 +1312,13 @@ func (s *Scanner) processPhase(
|
||||
|
||||
// Process each file
|
||||
for _, fileToProcess := range filesToProcess {
|
||||
// Check context cancellation
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
}
|
||||
|
||||
// Update progress
|
||||
if s.progress != nil {
|
||||
s.progress.GetStats().CurrentFile.Store(fileToProcess.Path)
|
||||
@@ -1369,6 +1376,11 @@ func (s *Scanner) processFileWithErrorHandling(
|
||||
|
||||
err := s.processFileStreaming(ctx, fileToProcess, result)
|
||||
if err != nil {
|
||||
// A cancelled run stops here even under --skip-errors, rather than
|
||||
// counting this file as failed and going on to the next one.
|
||||
if ctx.Err() != nil {
|
||||
return false, fmt.Errorf("processing file %s: %w", fileToProcess.Path, err)
|
||||
}
|
||||
// A packer/database/encryption/upload failure means the chunk's data
|
||||
// may not have been stored. Skipping the file would let the snapshot
|
||||
// record a file whose chunk is in no blob and cannot be restored, so
|
||||
|
||||
Reference in New Issue
Block a user