mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-09 05:35:19 +02:00
Ensure adds to disk cache are atomic
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user