Add dr-thumbs: a sharded, syncable thumbnail store

A thumbnail is the one derived artefact worth sending over the wire: it costs
a range fetch plus a decode to produce and is identical for every client
looking at the same file. A second device that downloads a shard gets a full
grid without fetching a byte of RAW.

Sharded at 25 MB, filled sequentially. The cap is about sync granularity, not
SQLite's limits — one growing database means every client re-downloads it
whenever a single thumbnail is added, whereas with sequential fill only the
newest shard is ever dirty and sealed shards are safe to cache forever.

Stored JPEG-encoded rather than as raw RGBA: a 256px RGBA buffer is ~256 KB
against ~20 KB encoded, and that 13x is transfer cost on every client.

Keyed on Nextcloud's oc:fileid, stable across server-side rename and move.

Assisted-by: LLM
This commit is contained in:
2026-08-09 20:38:12 +02:00
parent b6a5c0f090
commit d6ddd0703b
6 changed files with 1011 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
//! TRACES: NFR-ARCH-4
//! Thumbnail store errors.
//!
//! A thumbnail is a cache entry, never authoritative — every failure here is
//! recoverable by regenerating from the source, so nothing in this module is
//! fatal to the app.
/// Something went wrong reading or writing the store.
#[derive(Debug, thiserror::Error)]
pub enum ThumbError {
#[error("sqlite: {0}")]
Sqlite(#[from] rusqlite::Error),
/// The index names a shard whose file is absent — a partial sync, or a
/// manual deletion. The entry is treated as a miss and regenerated.
#[error("shard {0} is missing")]
MissingShard(u32),
#[error("io: {0}")]
Io(String),
}