diff options
author | Nick White <git@njw.name> | 2020-03-31 12:47:22 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2020-03-31 12:47:22 +0100 |
commit | e2a568ab276e1ac497c5b416f2094fb467f2a1a8 (patch) | |
tree | ab0c872fa88c452ff5c12b2e781da2b71fbba090 | |
parent | 1193a4cc04ded754d49e1d572ec4014ebe5e2c77 (diff) |
[bookpipeline] Stop using filepath.Join for storage keys, as we want to ensure it is always a / delimeter
-rw-r--r-- | cmd/bookpipeline/main.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/cmd/bookpipeline/main.go b/cmd/bookpipeline/main.go index ac57352..38fd037 100644 --- a/cmd/bookpipeline/main.go +++ b/cmd/bookpipeline/main.go @@ -22,8 +22,6 @@ import ( "rescribe.xyz/utils/pkg/hocr" ) -// TODO: stop using filepath.Join for keys; just use '/' delimeter - const usage = `Usage: bookpipeline [-v] [-np] [-nw] [-no] [-nop] [-na] [-t training] [-shutdown true/false] Watches the preprocess, ocr and analyse queues for book names. When @@ -96,7 +94,7 @@ func download(dl chan string, process chan string, conn Pipeliner, dir string, e 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) - key := filepath.Join(bookname, name) + key := bookname + "/" + name logger.Println("Uploading", key) err := conn.Upload(conn.WIPStorageId(), key, path) if err != nil { @@ -113,7 +111,7 @@ func up(c chan string, done chan bool, conn Pipeliner, bookname string, errc cha func upAndQueue(c chan string, done chan bool, toQueue string, conn Pipeliner, bookname string, training string, errc chan error, logger *log.Logger) { for path := range c { name := filepath.Base(path) - key := filepath.Join(bookname, name) + key := bookname + "/" + name logger.Println("Uploading", key) err := conn.Upload(conn.WIPStorageId(), key, path) if err != nil { @@ -311,7 +309,7 @@ func analyse(conn Pipeliner) func(chan string, chan string, chan error, *log.Log } logger.Println("Downloading binarised page to add to PDF", binfn) - err := conn.Download(conn.WIPStorageId(), filepath.Join(bookname, binfn), filepath.Join(savedir, binfn)) + err := conn.Download(conn.WIPStorageId(), bookname + "/" + binfn), filepath.Join(savedir, binfn)) if err != nil { logger.Println("Download failed; skipping page", binfn) } else { @@ -325,11 +323,11 @@ func analyse(conn Pipeliner) func(chan string, chan string, chan error, *log.Log } logger.Println("Downloading colour page to add to PDF", colourfn) - err = conn.Download(conn.WIPStorageId(), filepath.Join(bookname, colourfn), filepath.Join(savedir, colourfn)) + err = conn.Download(conn.WIPStorageId(), bookname + "/" + colourfn, filepath.Join(savedir, colourfn)) if err != nil { colourfn = strings.Replace(colourfn, ".jpg", ".png", 1) logger.Println("Download failed; trying", colourfn) - err = conn.Download(conn.WIPStorageId(), filepath.Join(bookname, colourfn), filepath.Join(savedir, colourfn)) + err = conn.Download(conn.WIPStorageId(), bookname + "/" + colourfn, filepath.Join(savedir, colourfn)) if err != nil { logger.Println("Download failed; skipping page", colourfn) } |