forked from TrueCloudLab/restic
archiver: Don't loose error if background context is canceled
A canceled background context lets the blob/tree/fileSavers exit without reporting an error. The error handling previously replaced a 'context canceled' error received by the main backup method with the error reported by the savers. However, in case of a canceled background context that error is nil, causing restic to loose the error and save a snapshot with a nil tree.
This commit is contained in:
parent
9c41e4a343
commit
736e964317
1 changed files with 2 additions and 1 deletions
|
@ -803,7 +803,8 @@ func (arch *Archiver) Snapshot(ctx context.Context, targets []string, opts Snaps
|
|||
t.Kill(nil)
|
||||
werr := t.Wait()
|
||||
debug.Log("err is %v, werr is %v", err, werr)
|
||||
if err == nil || errors.Cause(err) == context.Canceled {
|
||||
// Use werr when it might contain a more specific error than "context canceled"
|
||||
if err == nil || (errors.Cause(err) == context.Canceled && werr != nil) {
|
||||
err = werr
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue