summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-08-22 10:23:19 +0100
committerNick White <git@njw.name>2019-08-22 10:23:19 +0100
commitbdedc2ca1e6fbcbc06cd124f1729a341bc13afe8 (patch)
treec3e62bc8847fec1ea1d124ddef561c8be3f09df9
parent7ba8858782bf0b2f998ccc15f91d839074df94fc (diff)
Fix process finishing by closing dl channel
-rw-r--r--pipelinepreprocess/main.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/pipelinepreprocess/main.go b/pipelinepreprocess/main.go
index 197dd9c..029ac76 100644
--- a/pipelinepreprocess/main.go
+++ b/pipelinepreprocess/main.go
@@ -60,18 +60,18 @@ type Qmsg struct {
Handle, Body string
}
-func download(dl chan string, pre chan string, conn Pipeliner, dir string, errc chan error) {
+func download(dl chan string, process chan string, conn Pipeliner, dir string, errc chan error) {
for key := range dl {
fn := filepath.Join(dir, filepath.Base(key))
err := conn.DownloadFromInProgress(key, fn)
if err != nil {
- close(pre)
+ close(process)
errc <- err
return
}
- pre <- fn
+ process <- fn
}
- close(pre)
+ close(process)
}
func up(c chan string, done chan bool, conn Pipeliner, bookname string, errc chan error) {
@@ -155,6 +155,7 @@ func preProcBook(msg Qmsg, conn Pipeliner) error {
for _, d := range todl {
dl <- d
}
+ close(dl)
// wait for either the done or errc channel to be sent to
select {
@@ -162,7 +163,7 @@ func preProcBook(msg Qmsg, conn Pipeliner) error {
t.Stop()
_ = os.RemoveAll(d)
return err
- case <- done:
+ case <-done:
}
conn.Logger().Println("Sending", bookname, "to OCR queue")
@@ -224,6 +225,7 @@ func ocrBook(msg Qmsg, conn Pipeliner) error {
for _, a := range todl {
dl <- a
}
+ close(dl)
// wait for either the done or errc channel to be sent to
select {
@@ -231,7 +233,7 @@ func ocrBook(msg Qmsg, conn Pipeliner) error {
t.Stop()
_ = os.RemoveAll(d)
return err
- case <- done:
+ case <-done:
}
conn.Logger().Println("Sending", bookname, "to analyse queue")