From f1dce0812200ca40b58445321e7445ba0a2ef235 Mon Sep 17 00:00:00 2001 From: Nick White Date: Mon, 31 May 2021 14:27:04 +0100 Subject: Add a test for up(), and document download() and up() properly --- internal/pipeline/pipeline.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'internal/pipeline/pipeline.go') diff --git a/internal/pipeline/pipeline.go b/internal/pipeline/pipeline.go index 72d7fd1..3836204 100644 --- a/internal/pipeline/pipeline.go +++ b/internal/pipeline/pipeline.go @@ -79,6 +79,10 @@ func GetMailSettings() (mailSettings, error) { return mailSettings{f[0], f[1], f[2], f[3], f[4], f[5]}, nil } +// download reads file names from a channel and downloads them into +// dir, putting each successfully downloaded file name into the +// process channel. If an error occurs it is sent to the errc channel +// and the function returns early. func download(dl chan string, process chan string, conn Pipeliner, dir string, errc chan error, logger *log.Logger) { for key := range dl { fn := filepath.Join(dir, filepath.Base(key)) @@ -96,6 +100,11 @@ func download(dl chan string, process chan string, conn Pipeliner, dir string, e close(process) } +// up reads file names from a channel and uploads them with +// the bookname/ prefix, removing the local copy of each file +// once it has been successfully uploaded. The done channel is +// then written to to signal completion. If an error occurs it +// is sent to the errc channel and the function returns early. func up(c chan string, done chan bool, conn Pipeliner, bookname string, errc chan error, logger *log.Logger) { for path := range c { name := filepath.Base(path) -- cgit v1.2.1-24-ge1ad