diff options
author | Nick White <git@njw.name> | 2020-11-16 17:43:27 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2020-11-16 17:43:27 +0000 |
commit | cfbb3481368714adcd734906d8a460b873551c90 (patch) | |
tree | c27b53cd40cd975a2773e832fff6b0b90160deb2 | |
parent | eefa8f50d7ab915ce426c837cf504d26b7d4ccee (diff) |
Some changes to ensure the pipeline works correctly on Windows
There were a couple of places where a file was uploaded while still open,
which resulted in an attempt to remove it, which causes an error from
Windows.
The allOCRed function also included an assumption that the path separator
would be a /, which is always correct for AWS, and correct for local on
Linux and OSX, but not for local Windows. Fixed by leaving the separator
well alone.
Also, the local connection was not stripping leading \, like it did /,
which caused an issue with Windows local.
Windows local is now tested and working, at least through wine.
-rw-r--r-- | internal/pipeline/pipeline.go | 5 | ||||
-rw-r--r-- | local.go | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/internal/pipeline/pipeline.go b/internal/pipeline/pipeline.go index 280e4d2..20400ad 100644 --- a/internal/pipeline/pipeline.go +++ b/internal/pipeline/pipeline.go @@ -269,6 +269,7 @@ func Analyse(conn Pipeliner) func(chan string, chan string, chan error, *log.Log } } } + f.Close() up <- fn logger.Println("Creating best file listing the best file for each page") @@ -282,6 +283,7 @@ func Analyse(conn Pipeliner) func(chan string, chan string, chan error, *log.Log for _, conf := range bestconfs { _, err = fmt.Fprintf(f, "%s\n", filepath.Base(conf.Path)) } + f.Close() up <- fn var pgs []string @@ -461,8 +463,7 @@ func allOCRed(bookname string, conn Pipeliner) bool { if preprocessedPattern.MatchString(png) { atleastone = true found := false - b := strings.TrimSuffix(filepath.Base(png), ".png") - hocrname := bookname + "/" + b + ".hocr" + hocrname := strings.TrimSuffix(png, ".png") + ".hocr" for _, hocr := range objs { if hocr == hocrname { found = true @@ -134,6 +134,7 @@ func prefixwalker(dirpath string, prefix string, list *[]ObjMeta) filepath.WalkF } n := strings.TrimPrefix(path, dirpath) n = strings.TrimPrefix(n, "/") + n = strings.TrimPrefix(n, "\\") o := ObjMeta{Name: n, Date: info.ModTime()} *list = append(*list, o) return nil |