fix(config): prevent overwriting default logPath (#1219)

* fix(config): prevent overwriting logPath default

* Fix duplication issue

* fix: Preserve non-empty logPath value in config
This commit is contained in:
soup 2023-10-30 23:04:53 +01:00 committed by GitHub
parent 9ddaea1aa2
commit 89d00d0986
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -316,7 +316,13 @@ func (c *AppConfig) processLines(lines []string) []string {
}
if !foundLineLogPath && strings.Contains(line, "logPath =") {
if c.Config.LogPath == "" {
lines[i] = `#logPath = ""`
// Check if the line already has a value
matches := strings.Split(line, "=")
if len(matches) > 1 && strings.TrimSpace(matches[1]) != `""` {
lines[i] = line // Preserve the existing line
} else {
lines[i] = `#logPath = ""`
}
} else {
lines[i] = fmt.Sprintf("logPath = \"%s\"", c.Config.LogPath)
}