mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-03 22:25:57 +00:00
Ensure adds to disk cache are atomic
This commit is contained in:
parent
e8cfedee07
commit
5d1ce327e0
1 changed files with 3 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue