fix: use filepath.Join everywhere for windows compatibility

This commit is contained in:
Gareth
2026-06-29 23:30:14 -07:00
parent 07babe4ddf
commit 6d5d80050d
2 changed files with 5 additions and 7 deletions
+3 -4
View File
@@ -11,7 +11,6 @@ import (
"net/http"
"os"
"os/signal"
"path"
"path/filepath"
"runtime"
"sync"
@@ -103,7 +102,7 @@ func runApp() {
zap.L().Fatal("error creating orchestrator", zap.Error(err))
}
kvdbPath := path.Join(env.DataDir(), "kvdb.sqlite")
kvdbPath := filepath.Join(env.DataDir(), "kvdb.sqlite")
sharedKvdb, err := kvstore.NewSqliteDbForKvStore(kvdbPath)
if err != nil {
zap.L().Fatal("error creating general kvstore database pool", zap.Error(err))
@@ -150,7 +149,7 @@ func createConfigStore() config.ConfigStore {
}
func newOpLog(cfg *v1.Config) (*oplog.OpLog, *sqlitestore.SqliteStore, error) {
oplogFile := path.Join(env.DataDir(), "oplog.sqlite")
oplogFile := filepath.Join(env.DataDir(), "oplog.sqlite")
opstore, err := sqlitestore.NewSqliteStore(oplogFile)
if errors.Is(err, sqlitestore.ErrLocked) {
zap.L().Fatal("oplog is locked by another instance of backrest", zap.String("data_dir", env.DataDir()))
@@ -197,7 +196,7 @@ func newLogStore(opLog *oplog.OpLog) (*logstore.LogStore, func(), error) {
}
func newAuthenticator(configMgr *config.ConfigManager) *auth.Authenticator {
secretFile := path.Join(env.DataDir(), "jwt-secret")
secretFile := filepath.Join(env.DataDir(), "jwt-secret")
data, err := os.ReadFile(secretFile)
if err != nil {
zap.L().Info("generating new auth secret")
+2 -3
View File
@@ -4,7 +4,6 @@ import (
"flag"
"fmt"
"os"
"path"
"path/filepath"
"runtime"
"strings"
@@ -51,13 +50,13 @@ func DataDir() string {
return val
}
if val := os.Getenv("XDG_DATA_HOME"); val != "" {
return path.Join(val, "backrest")
return filepath.Join(val, "backrest")
}
if runtime.GOOS == "windows" {
return filepath.Join(getConfigDir(), "backrest", "data")
}
return path.Join(getHomeDir(), ".local/share/backrest")
return filepath.Join(getHomeDir(), ".local", "share", "backrest")
}
func BindAddress() string {