perf: use `exec.LookPath` to check the path of external application

This commit is contained in:
Lykin 2024-04-02 17:25:53 +08:00
parent 4fd73411de
commit c7c647d728
4 changed files with 13 additions and 4 deletions

View File

@ -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,
}
}

View File

@ -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
}

View File

@ -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
}
}

View File

@ -117,6 +117,7 @@ func main() {
DisableFramelessWindowDecorations: true,
},
Linux: &linux.Options{
ProgramName: "Tiny RDM",
Icon: icon,
WebviewGpuPolicy: linux.WebviewGpuPolicyOnDemand,
WindowIsTranslucent: true,