Ir al contenido
GitHub

Client Filesystem

Unaudited

Esta página aún no está disponible en tu idioma.

Clients hold keys, so a client stores plaintext. Depending on the sync scope (Sync — Synchronization Scope), a library routinely holds assets whose original is server-only, so the layout represents an asset with or without its original. The layout is a contract: rebuild assumes exactly these names. Local Gallery owns the offline-first requirements it serves.

{library_root}/
├── media/{YYYY}/{YYYY-MM}/
│ ├── {uuid}.{ext} # original (plaintext; absent if not synced locally)
│ ├── {uuid}.cbor # canonical signed metadata sidecar
│ └── {uuid}.provenance.cbor # append-only signed provenance chain
├── cache/ # thumbnails/, meta/, transcodes/ — sharded {uuid[0:2]}/{uuid[2:4]}
├── index/library.sqlite # query + vector index, migrated in place
└── .library/
├── version, config, lock
├── docs/{albums,stacks}/{uuid}.cbor # signed album and stack label records
└── quarantine/{uuid}.{ext} + {uuid}.reason.json

Android and iOS use the app’s private sandbox with the same logical model. Rebuildable derivatives MUST NOT go in OS-managed cache locations: the OS evicts indiscriminately, and an expensive-to-regenerate thumbnail is not disposable.

The library root is excluded from the OS’s own cloud backup and device transfer, on every platform and API level, by the mechanisms in Platform Integrations — The Plaintext Boundary. It holds plaintext originals and sidecars; recovery is Capsule’s own (Backup and Recovery).

SQLite may lag the filesystem: a bundle is durable before its index rows commit. Opening the workspace re-indexes any bundle with no row from its sidecar (Library Maintenance and Atomic Writes — Atomic Writes and Crash Recovery). The client checks a file exists before acting on its row and rebuilds from sidecars on structural inconsistency (Library Maintenance and Atomic Writes).

Capsule reclaims space itself. Eligible: cache/ and fetched-but-unpinned originals. Never eligible: canonical media/ files the device holds as source of truth, sidecars, provenance chains and library.sqlite. An evicted representation re-fetches transparently via tiered fetch (Download — Tiered, On-Demand Fetch).

The reclaimable set is held within a user-configurable budget (capsule-library::library::cache_sweep):

  • Viewing stamps a last-access time; eviction is least-recently-accessed first.
  • At equal recency, evict original, then preview, then thumbnail. The metadata tier (sidecar + LQIP) is never reclaimed, so an asset always stays listable.
  • Pinned representations and device-owned originals are exempt from automatic eviction.

The budget scales with the connection class (Network Resilience — Connection Classes; capsule-sdk::cache_budget), because re-fetching an evicted representation grows costlier down the table:

Class Budget (× base) Bulk transfers
unmetered 1 Run
metered 2 Deferred
constrained 2 Deferred
adverse 3 Deferred
offline 4 Deferred

The base budget is a user setting (default 2 GiB, capsule cache budget --set); capsule cache sweep runs the sweep under the current plan. On a deferring class a push runs staged (Upload — Upload Tiering (Staged Uploads)) whatever the device’s upload policy, so the index tier still publishes each asset while preview and original wait for an unmetered link. The client samples the class through a port before each sweep and each transfer and re-plans when it changes. A desktop with no OS signal reports unmetered.

Releasing a device-owned original, by the user or through streaming import (Import Pipeline — Import-Upload Streaming Mode), MUST pass the verify-before-destroy gate (Durability — Verify Before Destroy). Once released it is an ordinary server-only, re-fetchable asset.

The client surfaces the largest consumers and lets the user delete selectively, pinned content included. It never touches canonical media/ files, and releasing a device-owned original is gated as above.

Free Up Space releases device copies of photos the server already holds, in bulk:

  • Filters. Captured before a cutoff date; keep chosen device albums, with messaging-app albums kept by default; keep favourites; photos, videos or both.
  • Review. A screen lists every candidate and the total bytes it reclaims before anything happens. Candidates that fail the verify-before-destroy gate (Durability — Verify Before Destroy) are listed as kept, with the reason, never released.
  • Release through the OS. A copy in the system photo library goes to the OS trash (PHAssetChangeRequest deletion on iOS, MediaStore.createTrashRequest on Android 11+), so the OS’s own recovery window still applies. A copy in the Capsule library becomes a server-only asset as above.
  • Never by surprise. Free Up Space runs only when the user confirms the review; no schedule or rule starts it.
  • Free Up Space is not implemented: there are no filters, no review screen and no OS-trash hand-off.
  • Init/open round-trip (unit). Directories and version/config present; re-open is idempotent.
  • Date bucketing (unit). Asset lands in media/{YYYY}/{YYYY-MM}/; unexplained drift triggers repair.
  • Lock contention (smoke). A second process is refused with a structured error.
  • Sandbox placement (smoke, per platform). Library in app-private storage; survives cold start; the root carries the platform’s exclude-from-backup marking.
  • Index rebuild (smoke). Drop library.sqlite; rebuild; every query over sidecar facts matches. Index-only state (cache bookkeeping, upload guards, importer-formed stack placement) is not expected back.
  • Eviction (unit). LRU order, tier order at equal recency, recency promotion, pin exemption; no canonical file touched; metadata tier never reclaimed.
  • Connection-class budget (unit). Each class yields its budget and bulk deferral; a class change mid-session re-plans without evicting pinned or device-owned originals.
  • Release gate (smoke). Non-durable verdict retains the original and surfaces it; durable releases.