Add more error handling

This commit is contained in:
Alexander Neumann
2021-01-30 19:35:46 +01:00
parent aef3658a5f
commit 0858fbf6aa
23 changed files with 91 additions and 36 deletions

View File

@@ -166,7 +166,7 @@ func (b *Backend) Load(ctx context.Context, h restic.Handle, length int, offset
if err == nil {
err = consumer(rd)
if err != nil {
rd.Close() // ignore secondary errors
_ = rd.Close() // ignore secondary errors
return err
}
return rd.Close()

View File

@@ -17,7 +17,12 @@ func TestCacheDirEnv(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer os.Unsetenv("RESTIC_CACHE_DIR")
defer func() {
err := os.Unsetenv("RESTIC_CACHE_DIR")
if err != nil {
t.Fatal(err)
}
}()
}
dir, err := DefaultDir()