Expand description
Import: scanning a source, planning against the library index, and executing the plan
(staged or streaming). The pure half — grouping, scope, default-album resolution and the
upload policy — is capsule_core::import, re-exported here so callers name one path.
Modules§
- default_
album - Default-album resolution — where an import lands when the user files it nowhere (SSoT: Organization — The Default Album).
- group
- scan
- scope
- The scope grammar — the canonical identity of an import source (SSoT: Organization — Scope Grammar).
- special
- upload
- Staged-upload contract types — the one canonical
UploadPolicy/UploadTierset (SSoT: Transfer — Upload: Upload Tiering (Staged Uploads)).
Structs§
- Camera
Adapter - The camera import source adapter, staging into
staging_root. - Camera
Object - One object on the camera, as the
CameraDeviceport describes it. - Camera
Receipt - The outcome of
CameraAdapter::receive. - Cancellation
Token - A token that can be used to cancel an in-progress import.
- Default
Album Context - Everything the resolution order reads. Each field is one rule’s input, in priority
order;
scopeis carried for traceability and for the post-v1 override rows. - Extracted
Import - The result of walking an export: normalized entries in a deterministic order.
- Extracted
Metadata - The out-of-band metadata an adapter folds for one media entry, with the precedence already
resolved. This is the artifact the Takeout mapping table validates, one field per rule, and
what
sidecar_enrichmentmaps onto the signed sidecar’s fields at import. - GeoPoint
- A WGS-84 point folded from either embedded EXIF or the exporter’s record.
- Import
Action Plan - Output of Phase 2 (plan).
- Import
Candidate - One logical “unit” of import — either a standalone file or a set of related files (RAW+JPEG pair, Live Photo HEIC+MOV, etc.).
- Import
Config - Configuration for an import run.
- Import
Execution Summary - Summary of a completed import run.
- Object
Failure - One object that could not be received.
- Plan
Counts - What the plan decided, counted. There is no “unsupported” bucket, by design: a file is imported, already held, or could not be read. Neither its format nor whether this build has a codec for it can keep it out of the library (issue #695).
- PtpCamera
- A camera reached over PTP/IP: an open session and the
DeviceInfoit reported. - Received
Object - One object received and staged.
- Resolved
Album - The album an import will land in, and the rule that chose it.
- Scan
Result - Output of Phase 1 (scan).
- Scope
- The canonical identity of an import source.
- Source
Entry - One normalized import entry: the
ImportCandidatethe pure planner consumes plus the folded exporterExtractedMetadatafor its primary media file. - Source
Metadata Index - The folded exporter metadata of a whole export, keyed by every source path it covers.
- Staged
Streaming Conflict - Raised when a staged upload policy is combined with a storage-constrained streaming import for the same run — the combination the planner rejects outright (transfer upload doc: “Staged and streaming import are mutually exclusive per import”).
- Storage
Failure - A storage, or the storage list itself, that the camera would not enumerate.
- Streamed
Outcome - The per-asset result of one window step, in window order.
- Streaming
Options - Everything the streaming window needs beyond the plan, the workspace, and the event sink.
- Streaming
Report - The outcome of a streaming import run.
- Takeout
Adapter - The Google Takeout import
SourceAdapter.
Enums§
- Adapter
Error - Errors surfaced while walking an export. Malformed per-file exporter metadata is tolerated (the entry degrades to no exporter record); these errors are reserved for failures that abort the whole extraction (no parts supplied, an unreadable root).
- Camera
Error - What can go wrong talking to the camera or staging what it sends.
- Default
Album Error - Failure to resolve a destination album.
- Fold
Source - Which side a folded field was ultimately taken from, per the precedence rule.
- Import
Decision - Decision for a single candidate.
- Import
Outcome - Outcome for a single imported file.
- Import
Progress Event - Progress events emitted during import execution.
- Import
Provider - The exporting service an adapter migrates from (for logs / telemetry / user-facing labels).
- Resolution
Rule - Which rule of the resolution order chose the destination album. Recorded on every resolution so a surprising destination is explainable after the fact.
- Source
Kind - What kind of source an import came from (closed enum; the wire value is the lowercase snake-case name, and a new kind is an additive protocol change).
- Special
Directory Status - Special
File Status - Special
Status - Stream
Halt - Why the window halted before draining the plan.
- Streamed
State - What became of one file in the streaming window.
- Streaming
Error - A streaming import that cannot start or cannot make progress. Per-asset upload pauses and
per-asset retain decisions are not errors — they are outcomes in the
StreamingReport; these variants are the hard stops. - Streaming
Event - Progress events for traceability / UI. The window is per-asset, so every state transition is observable.
- Upload
Halt - Why the streaming window must pause. A halt stops the loop from admitting further source files
into the library — continuing would refill the very disk streaming exists to spare. The
already-imported in-flight asset is retained locally; its upload resumes via the protocol’s
HEADresumption on reconnect, and the deterministic planner re-derives the not-yet-admitted work on the next run. - Upload
Policy - The per-device upload policy: a closed enum with exactly two members.
- Upload
Tier - The upload tier ladder, mirroring the download ladder. Tiers map directly onto
existing blob roles — no new blob kind exists for staging. The derived
Ordis the ladder order (Index < Preview < Original), so a scheduler emits sessions strictly T0 → T1 → T2 by sorting.
Constants§
- CAPTION_
MAX_ BYTES - The caption bound the metadata schema fixes (
caption_lww.value≤ 4096 bytes). A longer exporter description is truncated on a character boundary rather than dropped: the sidecar is a copy, and the exporter’s own JSON remains the untruncated record. - FAVORITE_
RATING - The star rating an exporter-side “favorite” maps to — the top of the 0–5 scale.
- IMPORT_
SCOPE_ V1 - Domain-separation label for
Scope::scope_id(versioned; a construction change bumps the suffix, exactly as for the device-cohort hash). - PRIMARY_
EXTS - RAW_
EXTS - VIDEO_
EXTS
Traits§
- Asset
Uploader - The network seam the streaming window drives to hand one just-imported asset’s bundle
(original + derivatives + metadata) to the upload protocol.
Implemented by
capsule-sdk/CLI over the real upload client; tests supply a deterministic mock. Kept incapsule-coreas a trait so the streaming loop — and its release gating — is exercised without any network. Synchronous by construction: the offline data plane calls it; async callers resolve their futures before returning. - Camera
Device - The camera the adapter reads from. Read-only by construction: enumeration and reads only.
- Source
Adapter - A third-party import source adapter — the seam every provider importer implements.
Functions§
- ensure_
streaming_ compatible - The pure staged × streaming exclusion invariant.
- execute
- Phase 4 — execute the import plan against
workspace. - execute_
streaming - Drive a streaming import: the bounded per-asset import → upload → verify → release window over
plan, underopts. - execute_
with_ source_ metadata execute, with the folded metadata a third-party source adapter extracted attached to each file it covers.- group_
by_ stem - Group a flat list of files by directory+stem, assigning member roles.
- plan
- Phase 2 — decide what to do with each candidate from the scan.
- resolve_
default_ album - Resolve the destination album for an import, first match wins (SSoT: Organization — The Default Album).
- safe_
file_ name - The camera’s file name made safe to use as one path component on every platform, or
Nonewhere it cannot be. - scan_
paths - Phase 1 — scan source directories and build a list of
ImportCandidates. - sidecar_
enrichment - Map one folded exporter record onto the sidecar fields it enriches, or
Nonewhen the record carries nothing to write.