mirror of
https://github.com/restic/restic.git
synced 2026-09-28 23:10:31 +00:00
internal: check error before deferring file Close()
If there is an error, file will be `nil`. We should check the returned error before deferring file `Close()`.
This commit is contained in:
@@ -243,11 +243,10 @@ func (node Node) createFileAt(ctx context.Context, path string, repo Repository,
|
||||
}
|
||||
|
||||
f, err := fs.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600)
|
||||
defer f.Close()
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "OpenFile")
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
var buf []byte
|
||||
for _, id := range node.Content {
|
||||
|
||||
Reference in New Issue
Block a user