From 5329537a2f3a753db01480b536855436c93a2ceb Mon Sep 17 00:00:00 2001 From: josc146 Date: Sat, 3 Feb 2024 20:29:56 +0800 Subject: [PATCH] improve path processing --- backend-golang/app.go | 7 ++++++- main.go | 12 ++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/backend-golang/app.go b/backend-golang/app.go index 3257a10..dda75f0 100644 --- a/backend-golang/app.go +++ b/backend-golang/app.go @@ -23,6 +23,7 @@ type App struct { ctx context.Context HasConfigData bool ConfigData map[string]any + Dev bool exDir string cmdPrefix string } @@ -48,7 +49,11 @@ func (a *App) OnStartup(ctx context.Context) { a.exDir = filepath.Dir(ex) + "/" a.cmdPrefix = "cd " + a.exDir + " && " } - os.Chdir(a.exDir) + if a.Dev { + a.exDir = "" + } else { + os.Chdir(a.exDir) + } } os.Chmod(a.exDir+"backend-rust/webgpu_server", 0777) diff --git a/main.go b/main.go index b1aa150..d97b8d6 100644 --- a/main.go +++ b/main.go @@ -67,9 +67,12 @@ var midiAssets embed.FS var components embed.FS func main() { - dev := true + // Create an instance of the app structure + app := backend.NewApp() + app.Dev = true + if buildInfo, ok := debug.ReadBuildInfo(); !ok || strings.Contains(buildInfo.String(), "-ldflags") { - dev = false + app.Dev = false backend.CopyEmbed(assets) os.RemoveAll("./py310/Lib/site-packages/cyac-1.7.dist-info") @@ -83,9 +86,6 @@ func main() { backend.CopyEmbed(components) } - // Create an instance of the app structure - app := backend.NewApp() - var zoomFactor float64 = 1.0 data, err := app.ReadJson("config.json") if err == nil { @@ -99,7 +99,7 @@ func main() { } var logger wailsLogger.Logger - if dev { + if app.Dev { logger = wailsLogger.NewDefaultLogger() } else { logger = wailsLogger.NewFileLogger("crash.log")