Skip to content

Commit

Permalink
feat: Externalize the data directory on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayideyia committed Sep 20, 2024
1 parent 093c19f commit 5c2cb33
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net"
"os"
"os/exec"
"os/user"
"path/filepath"
"strings"

Expand Down Expand Up @@ -51,7 +52,16 @@ func InitBridge() {
Env.BasePath = filepath.Dir(exePath)
Env.AppName = filepath.Base(exePath)

// step2: Read Config
// step2: Create a persistent data symlink
if Env.OS == "darwin" {
user, _ := user.Current()
linkPath := Env.BasePath + "/data"
appPath := "/Users/" + user.Username + "/Library/Application Support/" + Env.AppName
os.MkdirAll(appPath, os.ModePerm)
os.Symlink(appPath, linkPath)
}

// step3: Read Config
b, err := os.ReadFile(Env.BasePath + "/data/user.yaml")
if err == nil {
yaml.Unmarshal(b, &Config)
Expand Down

0 comments on commit 5c2cb33

Please sign in to comment.