mirror of https://github.com/restic/restic.git
detect and return error from file Close() in Node.createFileAt()
gh-1385
This commit is contained in:
parent
bcdebfb84e
commit
f5fa602482
|
@ -253,8 +253,26 @@ func (node Node) createFileAt(ctx context.Context, path string, repo Repository,
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "OpenFile")
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
err = node.writeNodeContent(ctx, repo, f)
|
||||
closeErr := f.Close()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if closeErr != nil {
|
||||
return errors.Wrap(closeErr, "Close")
|
||||
}
|
||||
|
||||
if node.Links > 1 {
|
||||
idx.Add(node.Inode, node.DeviceID, path)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (node Node) writeNodeContent(ctx context.Context, repo Repository, f *os.File) (error) {
|
||||
var buf []byte
|
||||
for _, id := range node.Content {
|
||||
size, err := repo.LookupBlobSize(id, DataBlob)
|
||||
|
@ -279,10 +297,6 @@ func (node Node) createFileAt(ctx context.Context, path string, repo Repository,
|
|||
}
|
||||
}
|
||||
|
||||
if node.Links > 1 {
|
||||
idx.Add(node.Inode, node.DeviceID, path)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue