Hwaro::Core::Build::Cache
Inherits Reference / Object
Build cache manager for tracking file changes
Constants
Default cache filename - uses dot prefix to hide from directory listings and 'hwaro_' prefix to identify it as project-specific cache
Constructors
Class methods
Compute a checksum for the config file
Compute a checksum for the effective (env-merged, env-substituted)
config plus the active env name and resolved base_url. Hashing the
parsed config.raw rather than the raw config.toml bytes means an
env override file (config.<env>.toml), changed ${ENV_VAR}
substitutions, or a --base-url override all invalidate the per-page
cache — none of which the file-bytes hash above can detect — while a
formatting-only edit to config.toml no longer forces a full rebuild.
Compute a combined checksum for a set of template files. Fields are length-prefixed (see DigestUtils) so adjacent name/content pairs can't produce the same byte stream across boundaries, which would have failed to invalidate.
Instance methods
Check if a file has changed since last build.
template_hash is the page's template closure fingerprint; nil
skips the comparison (non-page entries, or dependency tracking off).
extra_outputs are secondary sibling output files (see [outputs])
that must also still exist on disk — a manually deleted index.json
forces a rebuild just like a deleted index.html does.
Compute MD5 checksum of a file's content (streaming to avoid loading large files entirely into memory)
Check multiple files for changes (returns changed files)
Secondary output files (beyond the primary HTML output) recorded for
file_path on the last build, or [] when the entry has none (or
doesn't exist). Used to detect a manually deleted sibling format
file and to locate stale files when a page's source is removed
(see Builder#stale_outputs_for_removed).
Has the global page set (content page metadata that listings render — path/url/title/date/weight/draft/section) changed since last build?
Record the current page/section-set fingerprints so the next build can detect a change; marks the cache dirty when either value moves.
Save cache to disk using atomic write (temp file + rename) to prevent corruption from partial writes (e.g. disk full, crash). No-op when nothing changed since load — a warm all-hits build otherwise re-serializes every entry just to write identical bytes.
Has the section set (section metadata that nav/menus render) changed?
Set the current build's template and config checksums.
A config change always invalidates all entries. A template change
invalidates all entries only when invalidate_on_template_change
is true — with template dependency tracking active, the builder
passes false and per-page closure hashes (see changed?) decide
which pages a template edit actually affects.
Update cache entry for a file.
template_hash is the page's template closure fingerprint; nil
stores the global templates checksum (non-page entries).
output_paths are the secondary sibling output files this page
emitted (see [outputs]); empty when the feature isn't in use.
Thread-safe: protected by mutex for concurrent parallel builds.