forked from TrueCloudLab/restic
Remove unused Writer arg to internal/dump.writeDump
This commit is contained in:
parent
8b758c78a3
commit
4f33eca634
4 changed files with 5 additions and 7 deletions
|
@ -16,11 +16,7 @@ type dumper interface {
|
||||||
dumpNode(ctx context.Context, node *restic.Node, repo restic.Repository) error
|
dumpNode(ctx context.Context, node *restic.Node, repo restic.Repository) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteDump will write the contents of the given tree to the given destination.
|
func writeDump(ctx context.Context, repo restic.Repository, tree *restic.Tree, rootPath string, dmp dumper) error {
|
||||||
// It will loop over all nodes in the tree and dump them recursively.
|
|
||||||
type WriteDump func(ctx context.Context, repo restic.Repository, tree *restic.Tree, rootPath string, dst io.Writer) error
|
|
||||||
|
|
||||||
func writeDump(ctx context.Context, repo restic.Repository, tree *restic.Tree, rootPath string, dmp dumper, dst io.Writer) error {
|
|
||||||
for _, rootNode := range tree.Nodes {
|
for _, rootNode := range tree.Nodes {
|
||||||
rootNode.Path = rootPath
|
rootNode.Path = rootPath
|
||||||
err := dumpTree(ctx, repo, rootNode, rootPath, dmp)
|
err := dumpTree(ctx, repo, rootNode, rootPath, dmp)
|
||||||
|
|
|
@ -3,6 +3,7 @@ package dump
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/archiver"
|
"github.com/restic/restic/internal/archiver"
|
||||||
|
@ -27,6 +28,7 @@ func prepareTempdirRepoSrc(t testing.TB, src archiver.TestDir) (tempdir string,
|
||||||
}
|
}
|
||||||
|
|
||||||
type CheckDump func(t *testing.T, testDir string, testDump *bytes.Buffer) error
|
type CheckDump func(t *testing.T, testDir string, testDump *bytes.Buffer) error
|
||||||
|
type WriteDump func(ctx context.Context, repo restic.Repository, tree *restic.Tree, rootPath string, dst io.Writer) error
|
||||||
|
|
||||||
func WriteTest(t *testing.T, wd WriteDump, cd CheckDump) {
|
func WriteTest(t *testing.T, wd WriteDump, cd CheckDump) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
|
|
@ -23,7 +23,7 @@ var _ dumper = tarDumper{}
|
||||||
func WriteTar(ctx context.Context, repo restic.Repository, tree *restic.Tree, rootPath string, dst io.Writer) error {
|
func WriteTar(ctx context.Context, repo restic.Repository, tree *restic.Tree, rootPath string, dst io.Writer) error {
|
||||||
dmp := tarDumper{w: tar.NewWriter(dst)}
|
dmp := tarDumper{w: tar.NewWriter(dst)}
|
||||||
|
|
||||||
return writeDump(ctx, repo, tree, rootPath, dmp, dst)
|
return writeDump(ctx, repo, tree, rootPath, dmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dmp tarDumper) Close() error {
|
func (dmp tarDumper) Close() error {
|
||||||
|
|
|
@ -21,7 +21,7 @@ var _ dumper = zipDumper{}
|
||||||
func WriteZip(ctx context.Context, repo restic.Repository, tree *restic.Tree, rootPath string, dst io.Writer) error {
|
func WriteZip(ctx context.Context, repo restic.Repository, tree *restic.Tree, rootPath string, dst io.Writer) error {
|
||||||
dmp := zipDumper{w: zip.NewWriter(dst)}
|
dmp := zipDumper{w: zip.NewWriter(dst)}
|
||||||
|
|
||||||
return writeDump(ctx, repo, tree, rootPath, dmp, dst)
|
return writeDump(ctx, repo, tree, rootPath, dmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dmp zipDumper) Close() error {
|
func (dmp zipDumper) Close() error {
|
||||||
|
|
Loading…
Reference in a new issue