Content fingerprint from the diff patch. Changes whenever the underlying diff * changes, allowing per-file cache invalidation without a global flush.
(file: DiffFile)
| 68 | /** Content fingerprint from the diff patch. Changes whenever the underlying diff |
| 69 | * changes, allowing per-file cache invalidation without a global flush. */ |
| 70 | function patchFingerprint(file: DiffFile) { |
| 71 | const { patch } = file; |
| 72 | if (patch.length === 0) { |
| 73 | return metadataFingerprint(file); |
| 74 | } |
| 75 | |
| 76 | const mid = Math.floor(patch.length / 2); |
| 77 | return `${patch.length}:${patch.slice(0, 64)}:${patch.slice(mid, mid + 64)}:${patch.slice(-64)}`; |
| 78 | } |
| 79 | |
| 80 | /** Cache key that includes a content fingerprint so stale entries are never served |
| 81 | * after reload. Unchanged files keep their cache hit across reloads. */ |
no test coverage detected