Check if files need to be processed using two-layer detection. Delegates to ``zccache-fingerprint --cache-type two-layer check``. Exit 0 = run needed (files changed). Exit 1 = skip (cache hit, no changes). Use ``ext`` + ``root`` for fastest scanning (simple
(
self,
include: list[str] | None = None,
exclude: list[str] | None = None,
*,
root: str = ".",
ext: list[str] | None = None,
)
| 423 | self.cache_file = self.fingerprint_dir / f"{subpath}.json" |
| 424 | |
| 425 | def check_needs_update( |
| 426 | self, |
| 427 | include: list[str] | None = None, |
| 428 | exclude: list[str] | None = None, |
| 429 | *, |
| 430 | root: str = ".", |
| 431 | ext: list[str] | None = None, |
| 432 | ) -> bool: |
| 433 | """ |
| 434 | Check if files need to be processed using two-layer detection. |
| 435 | |
| 436 | Delegates to ``zccache-fingerprint --cache-type two-layer check``. |
| 437 | Exit 0 = run needed (files changed). |
| 438 | Exit 1 = skip (cache hit, no changes). |
| 439 | |
| 440 | Use ``ext`` + ``root`` for fastest scanning (simple suffix match, |
| 441 | scoped directory walk). Use ``include`` for glob-pattern matching. |
| 442 | |
| 443 | Args: |
| 444 | include: Glob patterns for files to monitor (e.g., ["src/**/*.cpp"]). |
| 445 | Cannot be combined with ``ext``. |
| 446 | exclude: Optional patterns to exclude. |
| 447 | root: Root directory for scanning (default: "."). |
| 448 | ext: File extensions without dot (e.g., ["h", "cpp"]). |
| 449 | Faster than ``include`` — uses simple suffix match. |
| 450 | Cannot be combined with ``include``. |
| 451 | |
| 452 | Returns: |
| 453 | True if processing is needed, False if cache is valid. |
| 454 | """ |
| 455 | # zccache-fp 1.3.10 fails to canonicalize a relative "." root |
| 456 | # ("scan error in : cannot canonicalize root"); always pass absolute. |
| 457 | abs_root = str(Path(root).resolve()) |
| 458 | args = [ |
| 459 | "--cache-file", |
| 460 | str(self.cache_file), |
| 461 | "--cache-type", |
| 462 | "two-layer", |
| 463 | "check", |
| 464 | "--root", |
| 465 | abs_root, |
| 466 | ] |
| 467 | if ext: |
| 468 | for e in ext: |
| 469 | args.extend(["--ext", e]) |
| 470 | elif include: |
| 471 | for pattern in include: |
| 472 | args.extend(["--include", pattern]) |
| 473 | if exclude: |
| 474 | for pattern in exclude: |
| 475 | args.extend(["--exclude", pattern]) |
| 476 | |
| 477 | result = _run_zccache(args) |
| 478 | # exit 0 = run needed, exit 1 = skip (cache hit), exit 2+ = error (fail-safe: run) |
| 479 | return result.returncode != 1 |
| 480 | |
| 481 | def mark_success(self) -> None: |
| 482 | """ |