diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/rescribe/gui.go | 8 | ||||
-rw-r--r-- | cmd/rescribe/main.go | 32 | ||||
-rw-r--r-- | cmd/rescribe/xyz.rescribe.rescribe.yml | 16 |
3 files changed, 43 insertions, 13 deletions
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 } diff --git a/cmd/rescribe/main.go b/cmd/rescribe/main.go index b33a66c..f532678 100644 --- a/cmd/rescribe/main.go +++ b/cmd/rescribe/main.go @@ -241,11 +241,33 @@ These training files are included in rescribe, and are always available: } } - // if trainingPath doesn't exist, set it to the embedded training instead - _, err = os.Stat(trainingPath) - if err != nil && !os.IsExist(err) { - trainingPath = filepath.Base(trainingPath) - trainingPath = filepath.Join(tessdatadir, trainingPath) + // copy training path to the tessdir directory, so that we can keep that a + // writeable space, which is needed opening other trainings in sandboxes + // like flatpak + in, err := os.Open(trainingPath) + trainingPath = filepath.Join(tessdatadir, filepath.Base(trainingPath)) + if err != nil { + in, err = os.Open(trainingPath) + if err != nil { + log.Fatalf("Error opening training file %s: %v", trainingPath, err) + } + } + defer in.Close() + newPath := trainingPath + ".new" + out, err := os.Create(newPath) + if err != nil { + log.Fatalf("Error creating training file %s: %v", newPath, err) + } + defer out.Close() + _, err = io.Copy(out, in) + if err != nil { + log.Fatalf("Error copying training file to %s: %v", newPath, err) + } + in.Close() + out.Close() + err = os.Rename(newPath, trainingPath) + if err != nil { + log.Fatalf("Error moving new training file to %s: %v", trainingPath, err) } abstraining, err := filepath.Abs(trainingPath) diff --git a/cmd/rescribe/xyz.rescribe.rescribe.yml b/cmd/rescribe/xyz.rescribe.rescribe.yml index ae87d59..d994b88 100644 --- a/cmd/rescribe/xyz.rescribe.rescribe.yml +++ b/cmd/rescribe/xyz.rescribe.rescribe.yml @@ -1,6 +1,6 @@ app-id: xyz.rescribe.rescribe runtime: org.freedesktop.Platform -runtime-version: '22.08' +runtime-version: '23.08' sdk: org.freedesktop.Sdk sdk-extensions: org.freedesktop.Sdk.Extension.golang build-options: @@ -30,12 +30,16 @@ modules: - cp -r tessdata/* $FLATPAK_DEST/share/tessdata/ sources: - type: git - url: https://github.com/rescribe/bookpipeline - tag: v1.1.0 - commit: 3dd003691436ed954d3b7de54affbb10b509d5a6 + url: ../.. + commit: HEAD + #url: https://github.com/rescribe/bookpipeline + #tag: v1.1.0 + #commit: 3dd003691436ed954d3b7de54affbb10b509d5a6 - type: archive - url: https://rescribe.xyz/rescribe/modules-20230213-3dd003.tar.xz - sha256: 36553c4b97ceefc2c4711d18f26c98d89a9a610cb99bd2a38b7a0bbf3236eb4a + url: https://rescribe.xyz/tmp/modules.tar.xz # TODO: move to /rescribe once stable + sha256: 98b769cf61cc4178303e7d9e0aa0e036f819a46041aa442982713cb847e4657a + #url: https://rescribe.xyz/rescribe/modules-20230213-3dd003.tar.xz + #sha256: 36553c4b97ceefc2c4711d18f26c98d89a9a610cb99bd2a38b7a0bbf3236eb4a strip-components: 0 - type: archive url: https://rescribe.xyz/rescribe/embeds/tessdata.20220322.zip |