diff options
author | Nick White <git@njw.name> | 2022-01-31 16:29:10 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2022-01-31 16:29:10 +0000 |
commit | 7fe36a34e661e0ffc4d8cb98733e2f586cac9e8d (patch) | |
tree | 5cdd20baa37e02fafdcf374cff291f9f754e78ac /cmd/rescribe/gui.go | |
parent | e837154369ee72c8599b76c9deb879c47e2d4b39 (diff) |
rescribe: Add context cancelling to extractPdfImgs(), so it's no longer possible to get the gui into a bad state by cancelling before startProcess began (hopefully)
Diffstat (limited to 'cmd/rescribe/gui.go')
-rw-r--r-- | cmd/rescribe/gui.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/cmd/rescribe/gui.go b/cmd/rescribe/gui.go index 92d8f5b..f4ac9bd 100644 --- a/cmd/rescribe/gui.go +++ b/cmd/rescribe/gui.go @@ -380,11 +380,13 @@ func startGui(log log.Logger, cmd string, training string, tessdir string) error progressBar.SetValue(0.1) if strings.HasSuffix(dir.Text, ".pdf") && !f.IsDir() { - bookdir, err = extractPdfImgs(bookdir) + bookdir, err = extractPdfImgs(ctx, bookdir) if err != nil { - msg := fmt.Sprintf("Error opening PDF: %v\n", bookdir, err) - dialog.ShowError(errors.New(msg), myWindow) - fmt.Fprintf(os.Stderr, msg) + if !strings.HasSuffix(err.Error(), "context canceled") { + msg := fmt.Sprintf("Error opening PDF %s: %v\n", bookdir, err) + dialog.ShowError(errors.New(msg), myWindow) + fmt.Fprintf(os.Stderr, msg) + } progressBar.SetValue(0.0) gobtn.SetText("Process OCR") |