python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / tools / hover / fix-assets-path.patch
blob00b1900bf776bf505d74f368816ecc80ba7876d4
1 diff --git a/internal/fileutils/assets.go b/internal/fileutils/assets.go
2 index 83eacd9..0b80e51 100644
3 --- a/internal/fileutils/assets.go
4 +++ b/internal/fileutils/assets.go
5 @@ -1,28 +1,7 @@
6 //go:generate rice embed
7 package fileutils
9 -import (
10 - "os"
11 - "sync"
13 - rice "github.com/GeertJohan/go.rice"
14 - "github.com/go-flutter-desktop/hover/internal/log"
17 -var (
18 - assetsBox *rice.Box
19 - assetsBoxOnce sync.Once
22 // AssetsBox hover's assets box
23 -func AssetsBox() *rice.Box {
24 - assetsBoxOnce.Do(func() {
25 - var err error
26 - assetsBox, err = rice.FindBox("../../assets")
27 - if err != nil {
28 - log.Errorf("Failed to find hover assets: %v", err)
29 - os.Exit(1)
30 - }
31 - })
32 - return assetsBox
33 +func AssetsBox() string {
34 + return "@assetsFolder@"
36 diff --git a/internal/fileutils/file.go b/internal/fileutils/file.go
37 index cb75563..3822e80 100644
38 --- a/internal/fileutils/file.go
39 +++ b/internal/fileutils/file.go
40 @@ -11,8 +11,6 @@ import (
41 "strings"
42 "text/template"
44 - rice "github.com/GeertJohan/go.rice"
46 "github.com/go-flutter-desktop/hover/internal/log"
49 @@ -215,24 +213,24 @@ func ExecuteTemplateFromFile(boxed, to string, templateData interface{}) {
52 // ExecuteTemplateFromAssetsBox create file from a template asset
53 -func ExecuteTemplateFromAssetsBox(boxed, to string, assetsBox *rice.Box, templateData interface{}) {
54 - templateString, err := assetsBox.String(boxed)
55 +func ExecuteTemplateFromAssetsBox(boxed, to string, assetsBox string, templateData interface{}) {
56 + templateString, err := ioutil.ReadFile(assetsBox + "/" + boxed)
57 if err != nil {
58 log.Errorf("Failed to find template file: %v\n", err)
59 os.Exit(1)
61 - executeTemplateFromString(templateString, to, templateData)
62 + executeTemplateFromString(string(templateString), to, templateData)
65 // CopyAsset copies a file from asset
66 -func CopyAsset(boxed, to string, assetsBox *rice.Box) {
67 +func CopyAsset(boxed string, to string, assetsBox string) {
68 file, err := os.Create(to)
69 if err != nil {
70 log.Errorf("Failed to create %s: %v", to, err)
71 os.Exit(1)
73 defer file.Close()
74 - boxedFile, err := assetsBox.Open(boxed)
75 + boxedFile, err := os.OpenFile(assetsBox + "/" + boxed, os.O_RDONLY, 0666)
76 if err != nil {
77 log.Errorf("Failed to find boxed file %s: %v", boxed, err)
78 os.Exit(1)