forked from TrueCloudLab/restic
archiver: Let saveTree report a canceled context as an error
If the context was canceled then saveTree might receive a treeID or not depending on the timing. This could cause saveTree to incorrectly return a nil treeID as valid. Fix this always returning an error when the context was canceled in the meantime.
This commit is contained in:
parent
736e964317
commit
fc60b560ba
1 changed files with 4 additions and 0 deletions
|
@ -178,6 +178,10 @@ func (arch *Archiver) saveTree(ctx context.Context, t *restic.Tree) (restic.ID,
|
||||||
s.TreeBlobs++
|
s.TreeBlobs++
|
||||||
s.TreeSize += uint64(len(buf))
|
s.TreeSize += uint64(len(buf))
|
||||||
}
|
}
|
||||||
|
// The context was canceled in the meantime, res.ID() might be invalid
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
return restic.ID{}, s, ctx.Err()
|
||||||
|
}
|
||||||
return res.ID(), s, nil
|
return res.ID(), s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue