mirror of
https://github.com/restic/restic.git
synced 2024-12-25 01:06:39 +00:00
detect and return error from file Close() in Node.createFileAt()
gh-1385
This commit is contained in:
parent
bcdebfb84e
commit
f5fa602482
1 changed files with 19 additions and 5 deletions
|
@ -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 a new issue