diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-10-19 16:51:14 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-10-19 16:51:14 +0200 |
commit | 2c6a08c5c3b0f7346fbfa3e2ee86b248ef6d78f7 (patch) | |
tree | 5dfc3701c042d16e13c6aee0ad9b1879f6cf566a /repo/export.go | |
parent | 157e94222bc72ebc27a05f694ca8e9558435ab5a (diff) | |
download | dna-backup-2c6a08c5c3b0f7346fbfa3e2ee86b248ef6d78f7.tar.gz dna-backup-2c6a08c5c3b0f7346fbfa3e2ee86b248ef6d78f7.zip |
try to make exports faster
Diffstat (limited to 'repo/export.go')
-rw-r--r-- | repo/export.go | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/repo/export.go b/repo/export.go index 7597ce4..2e23a93 100644 --- a/repo/export.go +++ b/repo/export.go @@ -32,31 +32,39 @@ func (r *Repo) Export(exporter export.Exporter) { var err error 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(compressed, c.Reader()) - if err != nil { - logger.Error(err) - } - } - compressed.Close() - } - input.Chunks.Close() + go exportChunks(chunks[i], r.chunkWriteWrapper, input.Chunks) 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() + if err = input.Recipe.Close(); err != nil { + logger.Error("export recipe ", err) + } }) 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) } - input.Files.Close() + if err = input.Files.Close(); err != nil { + logger.Error("export files ", err) + } }) <-end } } + +func exportChunks(chunks []IdentifiedChunk, wrapper utils.WriteWrapper, input io.WriteCloser) { + if len(chunks) > 0 { + compressed := wrapper(input) + for _, c := range chunks { + _, err := io.Copy(compressed, c.Reader()) + if err != nil { + logger.Error(err) + } + } + compressed.Close() + } + input.Close() +} |