archiver: Make sure backend error is passed up

This commit is contained in:
Alexander Neumann 2018-05-12 23:54:20 +02:00
parent c5e75d1c98
commit e43c9202a6
1 changed files with 3 additions and 1 deletions

View File

@ -218,6 +218,7 @@ func (arch *Archiver) SaveDir(ctx context.Context, snPath string, fi os.FileInfo
for _, name := range names {
// test if context has been cancelled
if ctx.Err() != nil {
debug.Log("context has been cancelled, aborting")
return FutureTree{}, ctx.Err()
}
@ -767,7 +768,8 @@ func (arch *Archiver) Snapshot(ctx context.Context, targets []string, opts Snaps
t.Kill(nil)
werr := t.Wait()
if err != nil && errors.Cause(err) == context.Canceled {
debug.Log("err is %v, werr is %v", err, werr)
if err == nil || errors.Cause(err) == context.Canceled {
err = werr
}