From bd1681cfe3554075b1b0827563b76c6b95bf8b94 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 18 Oct 2021 16:16:54 +0200 Subject: make the repo responsible of the export compression --- repo/export.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'repo') diff --git a/repo/export.go b/repo/export.go index bcadd06..7597ce4 100644 --- a/repo/export.go +++ b/repo/export.go @@ -22,6 +22,7 @@ import ( "github.com/n-peugnet/dna-backup/export" "github.com/n-peugnet/dna-backup/logger" + "github.com/n-peugnet/dna-backup/utils" ) func (r *Repo) Export(exporter export.Exporter) { @@ -32,22 +33,24 @@ func (r *Repo) Export(exporter export.Exporter) { end := make(chan bool) input := exporter.ExportVersion(end) if len(chunks[i]) > 0 { + compressed := r.chunkWriteWrapper(input.Chunks) for _, c := range chunks[i] { - _, err := io.Copy(input.Chunks, c.Reader()) + _, err := io.Copy(compressed, c.Reader()) if err != nil { logger.Error(err) } } - input.Chunks.Close() + compressed.Close() } - readDelta(r.versions[i], recipeName, r.chunkReadWrapper, func(rc io.ReadCloser) { + input.Chunks.Close() + readDelta(r.versions[i], recipeName, utils.NopReadWrapper, func(rc io.ReadCloser) { _, err = io.Copy(input.Recipe, rc) if err != nil { logger.Error("load recipe ", err) } input.Recipe.Close() }) - readDelta(r.versions[i], filesName, r.chunkReadWrapper, func(rc io.ReadCloser) { + readDelta(r.versions[i], filesName, utils.NopReadWrapper, func(rc io.ReadCloser) { _, err = io.Copy(input.Files, rc) if err != nil { logger.Error("load files ", err) -- cgit v1.2.3