diff options
Diffstat (limited to 'cmd/rescribe/main.go')
-rw-r--r-- | cmd/rescribe/main.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/cmd/rescribe/main.go b/cmd/rescribe/main.go index 229bf49..72a03d3 100644 --- a/cmd/rescribe/main.go +++ b/cmd/rescribe/main.go @@ -237,7 +237,7 @@ These training files are included in rescribe, and are always available: } if flag.NArg() < 1 || *usegui { - err := startGui(*verboselog, tessCommand, trainingName, *systess, tessdir) + err := startGui(*verboselog, tessCommand, trainingName, tessdir) err = os.RemoveAll(tessdir) if err != nil { log.Printf("Error removing tesseract directory %s: %v", tessdir, err) @@ -279,11 +279,18 @@ These training files are included in rescribe, and are always available: ispdf = true } - err = startProcess(*verboselog, tessCommand, bookdir, bookname, trainingName, *systess, savedir, tessdir) + err = startProcess(*verboselog, tessCommand, bookdir, bookname, trainingName, savedir, tessdir) if err != nil { log.Fatalln(err) } + if !*systess { + err = os.RemoveAll(tessdir) + if err != nil { + log.Printf("Error removing tesseract directory %s: %v", tessdir, err) + } + } + if ispdf { os.RemoveAll(filepath.Clean(filepath.Join(bookdir, ".."))) } @@ -392,7 +399,7 @@ func rmIfNotImage(f string) error { return nil } -func startProcess(logger log.Logger, tessCommand string, bookdir string, bookname string, trainingName string, systess bool, savedir string, tessdir string) error { +func startProcess(logger log.Logger, tessCommand string, bookdir string, bookname string, trainingName string, savedir string, tessdir string) error { _, err := exec.Command(tessCommand, "--help").Output() if err != nil { errmsg := "Error, Can't run Tesseract\n" @@ -449,13 +456,6 @@ func startProcess(logger log.Logger, tessCommand string, bookdir string, booknam return fmt.Errorf("Error removing temporary directory %s: %v", tempdir, err) } - if !systess { - err = os.RemoveAll(tessdir) - if err != nil { - return fmt.Errorf("Error removing tesseract directory %s: %v", tessdir, err) - } - } - hocrs, err := filepath.Glob(fmt.Sprintf("%s%s*.hocr", savedir, string(filepath.Separator))) if err != nil { return fmt.Errorf("Error looking for .hocr files: %v", err) |