Skip to main content

Module import

Module import 

Source
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/UploadTier set (SSoT: Transfer — Upload: Upload Tiering (Staged Uploads)).

Structs§

CameraAdapter
The camera import source adapter, staging into staging_root.
CameraObject
One object on the camera, as the CameraDevice port describes it.
CameraReceipt
The outcome of CameraAdapter::receive.
CancellationToken
A token that can be used to cancel an in-progress import.
DefaultAlbumContext
Everything the resolution order reads. Each field is one rule’s input, in priority order; scope is carried for traceability and for the post-v1 override rows.
ExtractedImport
The result of walking an export: normalized entries in a deterministic order.
ExtractedMetadata
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_enrichment maps onto the signed sidecar’s fields at import.
GeoPoint
A WGS-84 point folded from either embedded EXIF or the exporter’s record.
ImportActionPlan
Output of Phase 2 (plan).
ImportCandidate
One logical “unit” of import — either a standalone file or a set of related files (RAW+JPEG pair, Live Photo HEIC+MOV, etc.).
ImportConfig
Configuration for an import run.
ImportExecutionSummary
Summary of a completed import run.
ObjectFailure
One object that could not be received.
PlanCounts
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 DeviceInfo it reported.
ReceivedObject
One object received and staged.
ResolvedAlbum
The album an import will land in, and the rule that chose it.
ScanResult
Output of Phase 1 (scan).
Scope
The canonical identity of an import source.
SourceEntry
One normalized import entry: the ImportCandidate the pure planner consumes plus the folded exporter ExtractedMetadata for its primary media file.
SourceMetadataIndex
The folded exporter metadata of a whole export, keyed by every source path it covers.
StagedStreamingConflict
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”).
StorageFailure
A storage, or the storage list itself, that the camera would not enumerate.
StreamedOutcome
The per-asset result of one window step, in window order.
StreamingOptions
Everything the streaming window needs beyond the plan, the workspace, and the event sink.
StreamingReport
The outcome of a streaming import run.
TakeoutAdapter
The Google Takeout import SourceAdapter.

Enums§

AdapterError
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).
CameraError
What can go wrong talking to the camera or staging what it sends.
DefaultAlbumError
Failure to resolve a destination album.
FoldSource
Which side a folded field was ultimately taken from, per the precedence rule.
ImportDecision
Decision for a single candidate.
ImportOutcome
Outcome for a single imported file.
ImportProgressEvent
Progress events emitted during import execution.
ImportProvider
The exporting service an adapter migrates from (for logs / telemetry / user-facing labels).
ResolutionRule
Which rule of the resolution order chose the destination album. Recorded on every resolution so a surprising destination is explainable after the fact.
SourceKind
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).
SpecialDirectoryStatus
SpecialFileStatus
SpecialStatus
StreamHalt
Why the window halted before draining the plan.
StreamedState
What became of one file in the streaming window.
StreamingError
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.
StreamingEvent
Progress events for traceability / UI. The window is per-asset, so every state transition is observable.
UploadHalt
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 HEAD resumption on reconnect, and the deterministic planner re-derives the not-yet-admitted work on the next run.
UploadPolicy
The per-device upload policy: a closed enum with exactly two members.
UploadTier
The upload tier ladder, mirroring the download ladder. Tiers map directly onto existing blob roles — no new blob kind exists for staging. The derived Ord is 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§

AssetUploader
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 in capsule-core as 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.
CameraDevice
The camera the adapter reads from. Read-only by construction: enumeration and reads only.
SourceAdapter
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, under opts.
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 None where 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 None when the record carries nothing to write.