(
run: Run,
writes: ReadonlyArray<Write>,
skipped: Set<Entry>
)
| 6754 | } |
| 6755 | /** Returns the entries stored fresh, and adds those whose write was skipped to `skipped`. */ |
| 6756 | const applyWrites = ( |
| 6757 | run: Run, |
| 6758 | writes: ReadonlyArray<Write>, |
| 6759 | skipped: Set<Entry> |
| 6760 | ): Set<Entry> => { |
| 6761 | const fresh = new Set<Entry>() |
| 6762 | for (const set of writes) { |
| 6763 | const def = register(defOf(set.query)) |
| 6764 | const argsKey = argsKeyOf(set) |
| 6765 | const existing = lookup(def, argsKey) |
| 6766 | if ( |
| 6767 | existing !== undefined && existing.born <= run.startSeq && |
| 6768 | !targetsHit(run.targets, def.name, def.tags, argsKey) |
| 6769 | ) { |
| 6770 | const logKey = logKeyOf(existing) |
| 6771 | report( |
| 6772 | new UncoveredWrite({ |
| 6773 | query: def.name, |
| 6774 | logKey, |
| 6775 | command: run.command, |
| 6776 | message: "[Query] " + quote(run.command) + " wrote " + |
| 6777 | quote(def.name) + " at " + logKey + |
| 6778 | ", which neither its invalidates nor a patch covers. The write applies." |
| 6779 | }) |
| 6780 | ) |
| 6781 | } |
| 6782 | const entry = existing ?? ensureEntry(def, set.args, argsKey) |
| 6783 | // A run issued later has already reached the entry: this answer may be the older one, so it isn't stored, |
| 6784 | // and the entry is invalidated. |
| 6785 | if (entry.reached > run.issue) { |
| 6786 | skipped.add(entry) |
| 6787 | continue |
| 6788 | } |
| 6789 | entry.reached = run.issue |
| 6790 | if (entry.patches.some((patch) => patch.live && patch.run !== run)) { |
| 6791 | // Under another run's live patch it isn't stored, and the entry goes stale. |
| 6792 | entry.touched = ++seq |
| 6793 | if (entry.result !== undefined) entry.invalidated = true |
| 6794 | holdBack(entry, "invalidation", undefined) |
| 6795 | entry.deferredParent = run.span |
| 6796 | continue |
| 6797 | } |
| 6798 | const isFresh = entry.touched <= run.startSeq |
| 6799 | entry.touched = ++seq |
| 6800 | storeWrite(entry, set.value, isFresh, run.span) |
| 6801 | if (isFresh) fresh.add(entry) |
| 6802 | } |
| 6803 | return fresh |
| 6804 | } |
| 6805 | const beginRun: CacheInternals["beginRun"] = (runOptions) => { |
| 6806 | const optimistic = runOptions.optimistic ?? [] |
| 6807 | registerTargets(runOptions.invalidates) |
no test coverage detected