Check if files need to be processed. Delegates to ``zccache-fingerprint --cache-type hash check``. Exit 0 = run needed. Exit 1 = skip (cache hit). Use ``ext`` + ``root`` for fastest scanning (simple suffix match, scoped directory walk). Use ``include`` fo
(
self,
include: list[str] | None = None,
exclude: list[str] | None = None,
*,
root: str = ".",
ext: list[str] | None = None,
)
| 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"]). |
| 589 | Faster than ``include`` — uses simple suffix match. |
| 590 | Cannot be combined with ``include``. |
| 591 | |
| 592 | Returns: |
| 593 | True if processing is needed, False if cache is valid. |
| 594 | """ |
| 595 | abs_root = str(Path(root).resolve()) |
| 596 | args = [ |
| 597 | "--cache-file", |
| 598 | str(self.cache_file), |
| 599 | "--cache-type", |
| 600 | "hash", |
| 601 | "check", |
| 602 | "--root", |
| 603 | abs_root, |
| 604 | ] |
| 605 | if ext: |
| 606 | for e in ext: |
| 607 | args.extend(["--ext", e]) |
| 608 | elif include: |
| 609 | for pattern in include: |
| 610 | args.extend(["--include", pattern]) |
| 611 | if exclude: |
| 612 | for pattern in exclude: |
| 613 | args.extend(["--exclude", pattern]) |
| 614 | |
| 615 | result = _run_zccache(args) |
| 616 | |
| 617 | needs_update = result.returncode != 1 |
| 618 | |
| 619 | # Write timestamp file on change (preserves existing feature) |
| 620 | if needs_update and self.timestamp_file is not None: |
| 621 | self._write_timestamp_file() |
| 622 | |
| 623 | return needs_update |