Merge pull request #801 from gsd-build/fix/clear-artifacts-in-invalidateAllCaches
fix: include DB artifact cache in invalidateAllCaches (#793)
This commit is contained in:
commit
e695cccc91
2 changed files with 18 additions and 1 deletions
|
|
@ -12,16 +12,18 @@
|
|||
import { invalidateStateCache } from './state.js';
|
||||
import { clearPathCache } from './paths.js';
|
||||
import { clearParseCache } from './files.js';
|
||||
import { clearArtifacts } from './gsd-db.js';
|
||||
|
||||
/**
|
||||
* Invalidate all GSD runtime caches in one call.
|
||||
*
|
||||
* Call this after file writes, milestone transitions, merge reconciliation,
|
||||
* or any operation that changes .gsd/ contents on disk. Forgetting to clear
|
||||
* any single cache causes stale reads (see #431).
|
||||
* any single cache causes stale reads (see #431, #793).
|
||||
*/
|
||||
export function invalidateAllCaches(): void {
|
||||
invalidateStateCache();
|
||||
clearPathCache();
|
||||
clearParseCache();
|
||||
clearArtifacts();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -790,6 +790,21 @@ export function upsertRequirement(r: Requirement): void {
|
|||
/**
|
||||
* Insert or replace an artifact. Uses the `path` PK for idempotency.
|
||||
*/
|
||||
/**
|
||||
* Delete all rows from the artifacts table.
|
||||
* The artifacts table is a read cache — clearing it forces the next
|
||||
* deriveState() to fall through to disk reads (native Rust batch parse).
|
||||
* Safe to call when no database is open (no-op).
|
||||
*/
|
||||
export function clearArtifacts(): void {
|
||||
if (!currentDb) return;
|
||||
try {
|
||||
currentDb.exec('DELETE FROM artifacts');
|
||||
} catch {
|
||||
// Clearing a cache should never be fatal
|
||||
}
|
||||
}
|
||||
|
||||
export function insertArtifact(a: {
|
||||
path: string;
|
||||
artifact_type: string;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue