Build Path Cleanup

This commit is contained in:
2026-04-17 21:09:02 +02:00
parent d77b44c210
commit f32dd224fe
6 changed files with 178 additions and 35 deletions
+8
View File
@@ -1,6 +1,7 @@
package topdata
import (
"bytes"
"encoding/binary"
"encoding/json"
"fmt"
@@ -283,6 +284,13 @@ func saveTLKState(path string, doc tlkStateDocument) error {
return fmt.Errorf("marshal tlk state: %w", err)
}
raw = append(raw, '\n')
current, err := os.ReadFile(path)
if err == nil && bytes.Equal(current, raw) {
return nil
}
if err != nil && !os.IsNotExist(err) {
return fmt.Errorf("read %s: %w", path, err)
}
if err := os.WriteFile(path, raw, 0o644); err != nil {
return fmt.Errorf("write %s: %w", path, err)
}