MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / upsertFile

Method upsertFile

src/db/queries.ts:4466–4496  ·  view source on GitHub ↗

* Insert or update a file record

(file: FileRecord)

Source from the content-addressed store, hash-verified

4464 * Insert or update a file record
4465 */
4466 upsertFile(file: FileRecord): void {
4467 if (!this.stmts.upsertFile) {
4468 this.stmts.upsertFile = this.db.prepare(`
4469 INSERT INTO files (path, content_hash, language, size, modified_at, indexed_at, node_count, errors, generated)
4470 VALUES (@path, @contentHash, @language, @size, @modifiedAt, @indexedAt, @nodeCount, @errors, @generated)
4471 ON CONFLICT(path) DO UPDATE SET
4472 content_hash = @contentHash,
4473 language = @language,
4474 size = @size,
4475 modified_at = @modifiedAt,
4476 indexed_at = @indexedAt,
4477 node_count = @nodeCount,
4478 errors = @errors,
4479 generated = @generated
4480 `);
4481 }
4482
4483 this.stmts.upsertFile.run({
4484 path: file.path,
4485 contentHash: file.contentHash,
4486 language: file.language,
4487 size: file.size,
4488 modifiedAt: file.modifiedAt,
4489 indexedAt: file.indexedAt,
4490 nodeCount: file.nodeCount,
4491 errors: file.errors ? JSON.stringify(file.errors) : null,
4492 // The upsert always REWRITES the flag: a file that loses its banner in an
4493 // edit must lose the flag on the next sync, not keep a stale 1.
4494 generated: file.generated ? 1 : 0,
4495 });
4496 }
4497
4498 /**
4499 * Which of `filePaths` the index flagged as tool-generated (schema v9+).

Callers 3

storeFileBundleMethod · 0.95
storeExtractionResultMethod · 0.80
freshDbFunction · 0.80

Calls 2

prepareMethod · 0.65
runMethod · 0.65

Tested by 1

freshDbFunction · 0.64