mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-20 15:12:37 +00:00
choose-files: Reject stale preview cache writes
Recheck the path key before updating the cache. Include the inode so a replacement with the same size and modification time gets a different key. Version the key to invalidate previously cached previews. Retry once when a changed path still resolves to a regular file.
This commit is contained in:
parent
24fdd01944
commit
bc7d4664d8
6 changed files with 132 additions and 20 deletions
|
|
@ -104,11 +104,13 @@ func key_for_path(path, extra_key string) (key string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
s, err := os.Stat(resolved_path)
|
||||
info, err := os.Stat(resolved_path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
data := fmt.Sprintf("%s\x00%d\x00%d", resolved_path, s.Size(), s.ModTime().UnixNano())
|
||||
s := get_file_state(info)
|
||||
// Version the key so entries written with weaker source validation miss.
|
||||
data := fmt.Sprintf("v2\x00%s\x00%d\x00%d\x00%d", resolved_path, s.Inode, s.Size, s.ModTime.UnixNano())
|
||||
if extra_key != "" {
|
||||
data += "\x00" + extra_key
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue