On-disk cache for NBPR package artefacts.
Pure path/key logic lives in NBPR.Artifact; this module owns the I/O —
checking whether an artefact is already extracted, and atomically extracting
a downloaded tarball into the cache directory.
Extraction goes via a sibling temp directory and then a rename, so a failed extract never leaves a half-populated cache directory behind.
Summary
Functions
Extracts a downloaded tarball into the canonical cache directory for the given inputs.
Lists extracted artefacts in the cache root.
Removes a single cache entry by absolute path. Returns :ok.
Returns true when the artefact is already extracted into the cache
directory. Currently a presence check; manifest-based verification is added
alongside the resolver in a later commit.
Types
Functions
@spec extract!(Path.t(), NBPR.Artifact.build_inputs()) :: :ok
Extracts a downloaded tarball into the canonical cache directory for the given inputs.
The tarball is expected to contain exactly one top-level directory (matching
Nerves' --strip-components=1 convention); the contents of that directory
become the cache directory's contents. Extraction is atomic via a temp
directory + rename.
@spec list() :: [entry()]
Lists extracted artefacts in the cache root.
An entry is a cache-root subdirectory containing a manifest.json — this
skips siblings like dl/ (staged downloads) and system-source/. Each
entry carries its directory name, absolute path, parsed manifest (or nil
if the JSON is unreadable), and POSIX mtime. Sorted newest-first.
@spec remove!(Path.t()) :: :ok
Removes a single cache entry by absolute path. Returns :ok.
@spec valid?(NBPR.Artifact.build_inputs()) :: boolean()
Returns true when the artefact is already extracted into the cache
directory. Currently a presence check; manifest-based verification is added
alongside the resolver in a later commit.