From 436551c5e6f9d96f82fdf31e01e422b2a937b6ee Mon Sep 17 00:00:00 2001 From: Nick White Date: Mon, 10 Jan 2022 16:15:52 +0000 Subject: internal/pipeline: Have DownloadPdfs() try to download all PDFs, but only return an error if none downloaded, as there are times when the colour PDF will not exist, which is fine --- internal/pipeline/get.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'internal') diff --git a/internal/pipeline/get.go b/internal/pipeline/get.go index e9bb8b1..5e43c2b 100644 --- a/internal/pipeline/get.go +++ b/internal/pipeline/get.go @@ -66,14 +66,22 @@ func DownloadBestPngs(dir string, name string, conn Downloader) error { } func DownloadPdfs(dir string, name string, conn Downloader) error { + anydone := false + errmsg := "" for _, suffix := range []string{".colour.pdf", ".binarised.pdf"} { key := filepath.Join(name, name+suffix) fn := filepath.Join(dir, name+suffix) err := conn.Download(conn.WIPStorageId(), key, fn) if err != nil { - return fmt.Errorf("Failed to download PDF %s: %v", key, err) + _ = os.Remove(fn) + errmsg += fmt.Sprintf("Failed to download PDF %s: %v\n", key, err) + } else { + anydone = true } } + if anydone == false { + return fmt.Errorf("No PDFs could be downloaded, error(s): %v", errmsg) + } return nil } -- cgit v1.2.1-24-ge1ad