Ensure adds to disk cache are atomic

This commit is contained in:
Kovid Goyal
2025-10-07 09:14:14 +05:30
parent e8cfedee07
commit 5d1ce327e0

View File

@@ -296,6 +296,9 @@ func (dc *DiskCache) add(key string, items map[string][]byte) (err error) {
}
changed -= before
} else {
// unlink the file so that writing to it does not change a
// previously linked copy created by get()
_ = os.Remove(p)
if err = os.WriteFile(p, data, 0o700); err != nil {
return
}