From c7c647d728e122ece17653fb446ed24a33aae813 Mon Sep 17 00:00:00 2001 From: Lykin <137850705+tiny-craft@users.noreply.github.com> Date: Tue, 2 Apr 2024 17:25:53 +0800 Subject: [PATCH] perf: use `exec.LookPath` to check the path of external application --- backend/storage/preferences.go | 4 +++- backend/utils/convert/php_convert.go | 6 +++++- backend/utils/convert/pickle_convert.go | 6 ++++-- main.go | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/backend/storage/preferences.go b/backend/storage/preferences.go index 261bb79..c30379f 100644 --- a/backend/storage/preferences.go +++ b/backend/storage/preferences.go @@ -17,8 +17,10 @@ type PreferencesStorage struct { } func NewPreferences() *PreferencesStorage { + storage := NewLocalStore("preferences.yaml") + log.Printf("preferences path: %s\n", storage.ConfPath) return &PreferencesStorage{ - storage: NewLocalStore("preferences.yaml"), + storage: storage, } } diff --git a/backend/utils/convert/php_convert.go b/backend/utils/convert/php_convert.go index b546d1d..1fb9160 100644 --- a/backend/utils/convert/php_convert.go +++ b/backend/utils/convert/php_convert.go @@ -1,5 +1,9 @@ package convutil +import ( + "os/exec" +) + type PhpConvert struct { CmdConvert } @@ -47,7 +51,7 @@ func NewPhpConvert() *PhpConvert { } var err error - if _, err = runCommand(c.DecodePath, "-v"); err != nil { + if _, err = exec.LookPath(c.DecodePath); err != nil { return nil } diff --git a/backend/utils/convert/pickle_convert.go b/backend/utils/convert/pickle_convert.go index e17cf13..4d945d0 100644 --- a/backend/utils/convert/pickle_convert.go +++ b/backend/utils/convert/pickle_convert.go @@ -1,5 +1,7 @@ package convutil +import "os/exec" + type PickleConvert struct { CmdConvert } @@ -40,9 +42,9 @@ func NewPickleConvert() *PickleConvert { } c.DecodePath, c.EncodePath = "python3", "python3" var err error - if _, err = runCommand(c.DecodePath, "--version"); err != nil { + if _, err = exec.LookPath(c.DecodePath); err != nil { c.DecodePath, c.EncodePath = "python", "python" - if _, err = runCommand(c.DecodePath, "--version"); err != nil { + if _, err = exec.LookPath(c.DecodePath); err != nil { return nil } } diff --git a/main.go b/main.go index 6d32253..851049e 100644 --- a/main.go +++ b/main.go @@ -117,6 +117,7 @@ func main() { DisableFramelessWindowDecorations: true, }, Linux: &linux.Options{ + ProgramName: "Tiny RDM", Icon: icon, WebviewGpuPolicy: linux.WebviewGpuPolicyOnDemand, WindowIsTranslucent: true,