mirror of
https://github.com/restic/restic.git
synced 2025-08-12 17:18:05 +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:
@@ -210,10 +210,10 @@ func updateNodeContent(node *restic.Node, results []saveResult) error {
|
||||
// Save for each chunk.
|
||||
func (arch *Archiver) SaveFile(ctx context.Context, p *restic.Progress, node *restic.Node) (*restic.Node, error) {
|
||||
file, err := fs.Open(node.Path)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
return node, errors.Wrap(err, "Open")
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
debug.RunHook("archiver.SaveFile", node.Path)
|
||||
|
||||
|
Reference in New Issue
Block a user