feat!: disable `--force-bin-dir` if `--data` is abs

related issues: #2580 #2542

after this commit, the `--force-bin-dir` would take no effect if `--data` is absolute path
pull/2587/head
Noah Hsu 2022-12-05 18:32:48 +08:00
parent bf8b6f4c2c
commit 97f1efbb72
1 changed files with 7 additions and 5 deletions

View File

@ -13,12 +13,14 @@ import (
func InitConfig() {
if flags.ForceBinDir {
if !filepath.IsAbs(flags.DataDir) {
ex, err := os.Executable()
if err != nil {
utils.Log.Fatal(err)
}
exPath := filepath.Dir(ex)
flags.DataDir = filepath.Join(exPath, "data")
flags.DataDir = filepath.Join(exPath, flags.DataDir)
}
}
configPath := filepath.Join(flags.DataDir, "config.json")
log.Infof("reading config file: %s", configPath)