change the atomic write functions to work with readers

This commit is contained in:
Kovid Goyal
2024-07-22 15:01:19 +05:30
parent d31c48092a
commit c906314974
7 changed files with 15 additions and 11 deletions

View File

@@ -3,6 +3,7 @@
package utils
import (
"bytes"
"encoding/json"
"fmt"
"os"
@@ -31,7 +32,7 @@ func (self *CachedValues[T]) Load() T {
func (self *CachedValues[T]) Save() {
raw, err := json.Marshal(self.Opts)
if err == nil {
AtomicUpdateFile(self.Path(), raw, 0o600)
AtomicUpdateFile(self.Path(), bytes.NewReader(raw), 0o600)
}
}