mirror of
https://github.com/restic/restic.git
synced 2025-08-12 11:47:43 +00:00
Merge pull request #1583 from restic/close-open-backend-files
Close backend files in case of errors
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user