Skip to content

Commit

Permalink
Better inproper shutdown handling
Browse files Browse the repository at this point in the history
  • Loading branch information
iann0036 committed Apr 29, 2023
1 parent bc2b263 commit 9412d19
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion iamlivecore/csm.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ func setConfigKey(filename, section, line string, unset bool) error {
scanner := bufio.NewScanner(file)
for scanner.Scan() {
scannedLine := scanner.Text()
if scannedLine != line || !unset || !isCorrectSection { // write all but lines to be removed
if scannedLine != line || !isCorrectSection { // write all but lines to be removed
newLines = append(newLines, scannedLine)
}
if scannedLine == fmt.Sprintf("[%s]", section) {
isCorrectSection = true
if !unset {
newLines = append(newLines, line)
}
} else if strings.HasPrefix(scannedLine, "[") && strings.HasSuffix(scannedLine, "]") {
isCorrectSection = false
}
}
if err := scanner.Err(); err != nil {
Expand Down

0 comments on commit 9412d19

Please sign in to comment.