Skip to main content

Module cache

Module cache 

Source
Expand description

Where finished icons are kept: a byte-bounded memory LRU, and a small disk cache so a restart doesn’t ask the shell again (spec §4.4). A type icon’s file name carries a hash of the file associations behind it, so changing a default app makes a new file instead of needing a notification.

Structs§

MemCache
Encoded PNGs by key, least recently used out first once over the cap.

Constants§

DISK_CAP_BYTES
Disk kept for type icons (a few hundred small files).
MEM_CAP_BYTES
Memory kept for encoded icons.

Functions§

disk_path
<root>/ext/<px>/<kind>-<ext>.<assoc>.png. The extension is validated to [a-z0-9_+-] and the kind prefix keeps a name like con from being a reserved device name on Windows.
key
The key a finished icon is kept under (memory and, hashed into the file name, disk).
prune
Delete the oldest files under root until what is left is at most cap bytes.
stable_hash
FNV-1a over the bytes: the same answer on every toolchain, since it names files that outlive a build.