Atomically update cached values file

This commit is contained in:
Kovid Goyal
2023-02-10 11:24:39 +05:30
parent cc5107d0db
commit 601a333b0e
2 changed files with 2 additions and 1 deletions

View File

@@ -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)