MCPcopy Create free account
hub / github.com/FastLED/FastLED / HashFingerprintCache

Class HashFingerprintCache

ci/fingerprint/core.py:531–690  ·  view source on GitHub ↗

Aggregate hash-based fingerprint cache backed by ``zccache-fingerprint`` CLI. Generates a single blake3 hash from the entire file set. All-or-nothing: if any file changes, the whole set is considered dirty. Best for "run all tests" or "compile all examples" style decisions.

Source from the content-addressed store, hash-verified

529
530
531class HashFingerprintCache:
532 """
533 Aggregate hash-based fingerprint cache backed by ``zccache-fingerprint`` CLI.
534
535 Generates a single blake3 hash from the entire file set. All-or-nothing:
536 if any file changes, the whole set is considered dirty.
537
538 Best for "run all tests" or "compile all examples" style decisions.
539 """
540
541 def __init__(
542 self,
543 cache_dir: Path,
544 subpath: str,
545 timestamp_file: Optional[Path] = None,
546 ):
547 """
548 Initialize hash fingerprint cache.
549
550 Args:
551 cache_dir: Base cache directory (e.g., Path(".cache"))
552 subpath: Subdirectory name for this cache (e.g., "js_lint", "native_build")
553 timestamp_file: Optional path to write timestamp when changes are detected.
554 """
555 self.cache_dir = cache_dir
556 self.subpath = subpath
557 self.timestamp_file = timestamp_file
558
559 # Create cache directory structure
560 self.fingerprint_dir = cache_dir / "fingerprint"
561 self.fingerprint_dir.mkdir(parents=True, exist_ok=True)
562
563 # Cache file path
564 self.cache_file = self.fingerprint_dir / f"{subpath}.json"
565
566 def check_needs_update(
567 self,
568 include: list[str] | None = None,
569 exclude: list[str] | None = None,
570 *,
571 root: str = ".",
572 ext: list[str] | None = None,
573 ) -> bool:
574 """
575 Check if files need to be processed.
576
577 Delegates to ``zccache-fingerprint --cache-type hash check``.
578 Exit 0 = run needed. Exit 1 = skip (cache hit).
579
580 Use ``ext`` + ``root`` for fastest scanning (simple suffix match,
581 scoped directory walk). Use ``include`` for glob-pattern matching.
582
583 Args:
584 include: Glob patterns for files to monitor.
585 Cannot be combined with ``ext``.
586 exclude: Optional patterns to exclude.
587 root: Root directory for scanning (default: ".").
588 ext: File extensions without dot (e.g., ["h", "cpp"]).

Calls

no outgoing calls