diff options
| -rw-r--r-- | cmd/rescribe/gui.go | 4 | ||||
| -rw-r--r-- | cmd/rescribe/main.go | 20 | 
2 files changed, 12 insertions, 12 deletions
diff --git a/cmd/rescribe/gui.go b/cmd/rescribe/gui.go index ce142fc..a532f99 100644 --- a/cmd/rescribe/gui.go +++ b/cmd/rescribe/gui.go @@ -95,7 +95,7 @@ func copyStderrToChan() (chan rune, error) {  }  // startGui starts the gui process -func startGui(log log.Logger, cmd string, training string, systess bool, tessdir string) error { +func startGui(log log.Logger, cmd string, training string, tessdir string) error {  	myApp := app.New()  	myWindow := myApp.NewWindow("Rescribe OCR") @@ -182,7 +182,7 @@ func startGui(log log.Logger, cmd string, training string, systess bool, tessdir  			}  		}() -		err = startProcess(log, cmd, dir.Text, filepath.Base(dir.Text), training, systess, dir.Text, tessdir) +		err = startProcess(log, cmd, dir.Text, filepath.Base(dir.Text), training, dir.Text, tessdir)  		if err != nil {  			// add a newline before this printing as another message from stdout  			// or stderr may well be half way through printing 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)  | 
