Classes
FileTrackingMixin
Mixin providing file tracking, hashing, and dependency management.
Requires these attributes on th…
FileTrackingMixin
Mixin providing file tracking, hashing, and dependency management.
Requires these attributes on the host class:
- file_hashes: dict[str, str]
- file_fingerprints: dict[str, dict[str, Any]]
- dependencies: dict[str, set[str]]
- output_sources: dict[str, str]
Attributes
| Name | Type | Description |
|---|---|---|
file_hashes |
dict[str, str] |
|
file_fingerprints |
dict[str, dict[str, Any]] |
|
dependencies |
dict[str, set[str]] |
|
output_sources |
dict[str, str] |
Methods 8
hash_file
Generate SHA256 hash of a file.
Delegates to centralized hash_file utility for…
hash_file
def hash_file(self, file_path: Path) -> str
Generate SHA256 hash of a file.
Delegates to centralized hash_file utility for consistent behavior.
Parameters 1
file_path |
Path |
Path to file |
Returns
Hex string of SHA256 hashstr
—
should_bypass
Determine if cache should be bypassed for a source file.
This is the single so…
should_bypass
def should_bypass(self, source_path: Path, changed_sources: set[Path] | None = None) -> bool
Determine if cache should be bypassed for a source file.
This is the single source of truth for cache bypass decisions (RFC: rfc-incremental-hot-reload-invariants).
Cache bypass is required when:
- File is in the changed_sources set (explicit change from file watcher)
- File hash differs from cached hash (is_changed check)
Parameters 2
source_path |
Path |
Path to source file |
changed_sources |
set[Path] | None |
Set of paths explicitly marked as changed (from file watcher) |
Returns
True if cache should be bypassed, False if cache can be usedbool
—
is_changed
Check if a file has changed since last build.
Performance Optimization (RFC: o…
is_changed
def is_changed(self, file_path: Path) -> bool
Check if a file has changed since last build.
Performance Optimization (RFC: orchestrator-performance-improvements):
- Fast path: mtime + size check (single stat call, no file read)
- Slow path: SHA256 hash only when mtime/size mismatch detected
- Handles edge cases: touch/rsync may change mtime but not content
Parameters 1
file_path |
Path |
Path to file |
Returns
True if file is new or has changed, False if unchangedbool
—
update_file
Update the fingerprint for a file (mtime + size + hash).
Performance Optimizat…
update_file
def update_file(self, file_path: Path) -> None
Update the fingerprint for a file (mtime + size + hash).
Performance Optimization:
Stores full fingerprint for fast change detection on subsequent builds.
Uses mtime + size for fast path, hash for verification.
Parameters 1
file_path |
Path |
Path to file |
track_output
Track the relationship between a source file and its output file.
This enables…
track_output
def track_output(self, source_path: Path, output_path: Path, output_dir: Path) -> None
Track the relationship between a source file and its output file.
This enables cleanup of output files when source files are deleted.
Parameters 3
source_path |
Path |
Path to source file (e.g., content/blog/post.md) |
output_path |
Path |
Absolute path to output file (e.g., /path/to/public/blog/post/index.html) |
output_dir |
Path |
Site output directory (e.g., /path/to/public) |
add_dependency
Record that a source file depends on another file.
add_dependency
def add_dependency(self, source: Path, dependency: Path) -> None
Record that a source file depends on another file.
Parameters 2
source |
Path |
Source file (e.g., content page) |
dependency |
Path |
Dependency file (e.g., template, partial, config) |
get_affected_pages
Find all pages that depend on a changed file.
get_affected_pages
def get_affected_pages(self, changed_file: Path) -> set[str]
Find all pages that depend on a changed file.
Parameters 1
changed_file |
Path |
File that changed |
Returns
Set of page paths that need to be rebuiltset[str]
—
invalidate_file
Remove a file from the cache (useful when file is deleted).
Note: This is a pa…
invalidate_file
def invalidate_file(self, file_path: Path) -> None
Remove a file from the cache (useful when file is deleted).
Note: This is a partial invalidation. Full invalidation of related caches (parsed_content, rendered_output, etc.) should be handled by the main BuildCache class.
Parameters 1
file_path |
Path |
Path to file |