Skip to main content

Module vcache

Module vcache 

Source
Expand description

Vector Cache: the pictures and media Vector keeps for itself (avatars, banners, emoji, icons, previews), sealed on disk under a per-install key so nothing in the app’s folders is a plain image to a gallery, an indexer or another app.

A file is VCC1 ‖ key id (4) ‖ nonce (12) ‖ ChaCha20 ciphertext. The stream seeks, so a video plays by range. A file written before sealing has no header and reads as it is.

Structs§

Sealer
A sealed file written a piece at a time, at any offset: a download’s part file, which a resume continues. Once whole it is a cache file as it stands.

Constants§

HEADER_LEN
Where a sealed file’s ciphertext starts.
KINDS
Vector’s caches under <app_data>/cache/. Nothing else there is Vector Cache: on Android the folder is the system’s own cache directory, which also holds the webview’s files.

Functions§

decode_rel
A request path’s segment text, percent-decoded.
is_sealed
Whether path is a sealed cache file: another app reading it would see only ciphertext.
open
A cache file read by range: what a player or a large picture asks for.
open_for_page
A cache file as a page may show it. A cached SVG is a render Vector drew and wrapped, so the page gets the picture inside, never SVG markup; anything else opens as it is.
read
The plaintext of a file Vector may have sealed: a cache file, sealed or from before sealing, and any other file as it is. A file under a lost key reads as missing, so its caller fetches it again and the write replaces it.
readable
Whether path holds a cache file this install can read, without reading it.
resolve
The cache file a page asks for by its path under the app’s folder: cache/… or an account’s wallpapers/…. Anything else, or any path that climbs out, is refused.
seal
Sealed plain, ready to write.
seal_dir
Seal every legacy picture and video under dir, recursively; sidecars and markers stay as they are. Returns how many were sealed.
seal_in_place
Seal a file written before sealing, in place. False when it was sealed already.
seal_legacy
Seal everything Vector cached before sealing: the shared cache and every account’s wallpapers. Idempotent; a sealed file costs one header read.
write
Write plain to path sealed: beside it first, then into place.
write_source
Write what src holds to path sealed, a chunk at a time: a large file never sits whole in memory, or plain on disk.