forked from TrueCloudLab/restic
Close backend files in case of errors
This commit is contained in:
parent
d62a664bb7
commit
909d9273cc
3 changed files with 4 additions and 0 deletions
1
internal/cache/backend.go
vendored
1
internal/cache/backend.go
vendored
|
@ -127,6 +127,7 @@ func (b *Backend) cacheFile(ctx context.Context, h restic.Handle) error {
|
|||
}
|
||||
|
||||
if err = b.Cache.Save(h, rd); err != nil {
|
||||
_ = rd.Close()
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -637,6 +637,7 @@ func checkPack(ctx context.Context, r restic.Repository, id restic.ID) error {
|
|||
|
||||
packfile, err := fs.TempFile("", "restic-temp-check-")
|
||||
if err != nil {
|
||||
_ = rd.Close()
|
||||
return errors.Wrap(err, "TempFile")
|
||||
}
|
||||
|
||||
|
@ -648,6 +649,7 @@ func checkPack(ctx context.Context, r restic.Repository, id restic.ID) error {
|
|||
hrd := hashing.NewReader(rd, sha256.New())
|
||||
size, err := io.Copy(packfile, hrd)
|
||||
if err != nil {
|
||||
_ = rd.Close()
|
||||
return errors.Wrap(err, "Copy")
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ func Repack(ctx context.Context, repo restic.Repository, packs restic.IDSet, kee
|
|||
hrd := hashing.NewReader(beRd, sha256.New())
|
||||
packLength, err := io.Copy(tempfile, hrd)
|
||||
if err != nil {
|
||||
_ = beRd.Close()
|
||||
return nil, errors.Wrap(err, "Copy")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue