From d2399a7ce0af49098a065c48409d1512f37c7c21 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 6 Feb 2024 08:17:24 +0000 Subject: Fix selecting a custom training file in flatpak This is done by copying any training to the temporary tesseract directory, and always using that as the TESSDIR. This works as it's writeable (unlike the /app/share directory that flatpak would otherwise work) --- cmd/rescribe/gui.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cmd/rescribe/gui.go') diff --git a/cmd/rescribe/gui.go b/cmd/rescribe/gui.go index 8790f03..73f1db2 100644 --- a/cmd/rescribe/gui.go +++ b/cmd/rescribe/gui.go @@ -134,14 +134,18 @@ func trainingSelectOnChange(sel *widget.Select, parent fyne.Window) func(string) newpath := filepath.Join(os.Getenv("TESSDATA_PREFIX"), name) f, err := os.Create(newpath) if err != nil { - // TODO: surface error somewhere, prob with a dialog box + msg := fmt.Sprintf("Error creating temporary file to store custom training: %v\n", err) + dialog.ShowError(errors.New(msg), parent) + fmt.Fprintf(os.Stderr, msg) sel.SetSelectedIndex(0) return } defer f.Close() _, err = io.Copy(f, uri) if err != nil { - // TODO: surface error somewhere, prob with a dialog box + msg := fmt.Sprintf("Error copying custom training to temporary file: %v\n", err) + dialog.ShowError(errors.New(msg), parent) + fmt.Fprintf(os.Stderr, msg) sel.SetSelectedIndex(0) return } -- cgit v1.2.1-24-ge1ad