(download []*remote.Change)
| 288 | } |
| 289 | |
| 290 | func (d *downstream) initDownload(download []*remote.Change) error { |
| 291 | reader, writer := io.Pipe() |
| 292 | |
| 293 | defer reader.Close() |
| 294 | defer writer.Close() |
| 295 | |
| 296 | errorChan := make(chan error) |
| 297 | go func() { |
| 298 | errorChan <- d.downloadFiles(writer, download) |
| 299 | }() |
| 300 | |
| 301 | // Untaring all downloaded files to the right location |
| 302 | // this can be a lengthy process when we downloaded a lot of files |
| 303 | err := d.unarchiver.Untar(reader, d.sync.LocalPath) |
| 304 | if err != nil { |
| 305 | return errors.Wrap(err, "untar files") |
| 306 | } |
| 307 | |
| 308 | return <-errorChan |
| 309 | } |
| 310 | |
| 311 | // downloadFiles downloads the given files from the remote server and writes the contents into the given writer |
| 312 | func (d *downstream) downloadFiles(writer io.WriteCloser, changes []*remote.Change) error { |
no test coverage detected