Deduplicate dumper closing logic

This commit is contained in:
DRON-666 2020-12-19 02:42:46 +03:00
parent e136dd8696
commit 83b10dbb12
3 changed files with 10 additions and 13 deletions

View file

@ -12,6 +12,7 @@ import (
// dumper implements saving node data.
type dumper interface {
io.Closer
dumpNode(ctx context.Context, node *restic.Node, repo restic.Repository) error
}
@ -24,11 +25,13 @@ func writeDump(ctx context.Context, repo restic.Repository, tree *restic.Tree, r
rootNode.Path = rootPath
err := dumpTree(ctx, repo, rootNode, rootPath, dmp)
if err != nil {
dmp.Close()
return err
}
}
return nil
return dmp.Close()
}
func dumpTree(ctx context.Context, repo restic.Repository, rootNode *restic.Node, rootPath string, dmp dumper) error {