aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-10-18 16:04:31 +0200
committern-peugnet <n.peugnet@free.fr>2021-10-18 16:04:31 +0200
commit56d1f553f32c242f7cc5043b9ce2b719e2285838 (patch)
treef73d85abb69b5b4a9f65aca197fcaf7dda40f99d
parent04563efa9c0dc1f6a36094dfd884ae432cf46b29 (diff)
downloaddna-backup-56d1f553f32c242f7cc5043b9ce2b719e2285838.tar.gz
dna-backup-56d1f553f32c242f7cc5043b9ce2b719e2285838.zip
make repo responsible of creating the export end channel
-rw-r--r--dna/drive.go5
-rw-r--r--export/exporter.go2
-rw-r--r--repo/export.go3
3 files changed, 5 insertions, 5 deletions
diff --git a/dna/drive.go b/dna/drive.go
index 0f62d5e..317d2f4 100644
--- a/dna/drive.go
+++ b/dna/drive.go
@@ -89,7 +89,7 @@ func New(
}
}
-func (d *DnaDrive) ExportVersion() (export.Input, <-chan bool) {
+func (d *DnaDrive) ExportVersion(end chan<- bool) export.Input {
rChunks, wChunks := io.Pipe()
rRecipe, wRecipe := io.Pipe()
rFiles, wFiles := io.Pipe()
@@ -105,9 +105,8 @@ func (d *DnaDrive) ExportVersion() (export.Input, <-chan bool) {
Files: rFiles,
},
}
- end := make(chan bool)
go d.writeVersion(version.Output, end)
- return version.Input, end
+ return version.Input
}
func (d *DnaDrive) writeVersion(output export.Output, end chan<- bool) {
diff --git a/export/exporter.go b/export/exporter.go
index 208fbd7..375ba15 100644
--- a/export/exporter.go
+++ b/export/exporter.go
@@ -20,5 +20,5 @@ type Output struct {
}
type Exporter interface {
- ExportVersion() (input Input, end <-chan bool)
+ ExportVersion(end chan<- bool) Input
}
diff --git a/repo/export.go b/repo/export.go
index dd12077..bcadd06 100644
--- a/repo/export.go
+++ b/repo/export.go
@@ -29,7 +29,8 @@ func (r *Repo) Export(exporter export.Exporter) {
chunks := r.loadChunks(r.versions)
for i := range r.versions {
var err error
- input, end := exporter.ExportVersion()
+ end := make(chan bool)
+ input := exporter.ExportVersion(end)
if len(chunks[i]) > 0 {
for _, c := range chunks[i] {
_, err := io.Copy(input.Chunks, c.Reader())