summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-11-09 18:29:56 +0000
committerNick White <git@njw.name>2020-11-09 18:54:50 +0000
commita1de8862a091f9584220db40671a0d43346c4519 (patch)
tree9f146b4cc90e117250dafcf7bfd64f7edc3907a1 /internal
parentfc6becf5ed98e9c0815532fd76639c15eb481ed1 (diff)
[rescribe] Local only combo tool basically now working. Testing is still minimal.
Diffstat (limited to 'internal')
-rw-r--r--internal/pipeline/get.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/internal/pipeline/get.go b/internal/pipeline/get.go
new file mode 100644
index 0000000..8492d99
--- /dev/null
+++ b/internal/pipeline/get.go
@@ -0,0 +1,58 @@
+// Copyright 2019 Nick White.
+// Use of this source code is governed by the GPLv3
+// license that can be found in the LICENSE file.
+
+package pipeline
+
+import (
+ "bufio"
+ "fmt"
+ "os"
+ "path/filepath"
+)
+
+func DownloadBestPages(name string, conn Pipeliner) error {
+ fn := filepath.Join(name, "best")
+ err := conn.Download(conn.WIPStorageId(), fn, fn)
+ if err != nil {
+ return fmt.Errorf("Failed to download 'best' file: %v", err)
+ }
+ f, err := os.Open(fn)
+ if err != nil {
+ return fmt.Errorf("Failed to open best file: %v", err)
+ }
+ defer f.Close()
+
+ s := bufio.NewScanner(f)
+ for s.Scan() {
+ fn = filepath.Join(name, s.Text())
+ err = conn.Download(conn.WIPStorageId(), fn, fn)
+ if err != nil {
+ return fmt.Errorf("Failed to download file %s: %v", fn, err)
+ }
+ }
+
+ return nil
+}
+
+func DownloadPdfs(name string, conn Pipeliner) error {
+ for _, suffix := range []string{".colour.pdf", ".binarised.pdf"} {
+ fn := filepath.Join(name, name+suffix)
+ err := conn.Download(conn.WIPStorageId(), fn, fn)
+ if err != nil {
+ return fmt.Errorf("Failed to download PDF %s: %v", fn, err)
+ }
+ }
+ return nil
+}
+
+func DownloadAnalyses(name string, conn Pipeliner) error {
+ for _, a := range []string{"conf", "graph.png"} {
+ fn := filepath.Join(name, a)
+ err := conn.Download(conn.WIPStorageId(), fn, fn)
+ if err != nil {
+ return fmt.Errorf("Failed to download analysis file %s: %v", fn, err)
+ }
+ }
+ return nil
+}