diff --git a/tools/utils/atomic-write.go b/tools/utils/atomic-write.go index 8e21d3f22..f67f1cd04 100644 --- a/tools/utils/atomic-write.go +++ b/tools/utils/atomic-write.go @@ -24,6 +24,7 @@ func AtomicWriteFile(path string, data []byte, perm os.FileMode) (err error) { f.Close() if !removed { os.Remove(f.Name()) + removed = true } }() _, err = f.Write(data) diff --git a/tools/utils/cached_values.go b/tools/utils/cached_values.go index 3785f4185..ced751557 100644 --- a/tools/utils/cached_values.go +++ b/tools/utils/cached_values.go @@ -31,7 +31,7 @@ func (self *CachedValues[T]) Load() T { func (self *CachedValues[T]) Save() { raw, err := json.Marshal(self.Opts) if err == nil { - os.WriteFile(self.Path(), raw, 0600) + AtomicUpdateFile(self.Path(), raw, 0o600) } }