Expand description
Image asset storage for the vault.
Images live as real files under <vault>/assets/<blake3hex16>.<ext>, keyed
by a content hash of their bytes so identical images dedup automatically.
Memos reference them with the app-relative oximg://<name> scheme, which the
Tauri shell resolves to the file (and browser-dev mode resolves to an
IndexedDB blob) — see the frontend lib/assets.ts.
Only the file store is touched (no index, no lock): assets are content addressed, so concurrent writers that produce the same bytes collide on the same filename harmlessly, and a partial write is simply overwritten.
Structs§
- Asset
Info - One row of the gallery: a discoverable asset plus its size and mtime.
- Asset
Ref - A reference returned to the frontend after saving an image.
urlis the exact string to drop into markdown (oximg://<name>);nameis the bare<hash>.<ext>used by the gallery and GC.
Constants§
- ALLOWED_
EXTS - Extensions the WKWebView can render inline. HEIC/RAW are excluded on purpose; convert upstream (or add a converter) before widening this set.
- HASH_
LEN - File-name stem length for a content-hashed asset (first 16 hex chars of a blake3 digest). 16 hex = 64 bits — ample collision resistance for a single user’s image library, and short enough to stay readable in raw markdown.
Functions§
- asset_
name - Content-hash raw image bytes to a bare asset name (
<hex16>.<ext>). - ext_of
- The extension portion of a validated asset name (without the dot), or
Noneif the name is malformed. - mime_
for_ ext - Content-Type for a whitelisted extension.
- normalize_
ext - Normalize an extension to lowercase ASCII without a leading dot, or reject anything outside the whitelist.
- refs_
in_ body - Extract every
oximg://<name>reference from a memo body. Used by the GC to decide which assets are still live.OXIMG_REis deliberately permissive on the markdown wrapper (, bare URL, or](…)-less fragments) so a reference survives even if a user hand-edits the alt text. - valid_
name - Strict validator for a served asset name. Permits only
<hex16>.<allowed>— no path separators, no.., no query/fragment. The protocol handler and the GC both gate on this.