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

Method upsertFile

src/db/queries.ts:4138–4168  ·  view source on GitHub ↗

* Insert or update a file record

(file: FileRecord)

Source from the content-addressed store, hash-verified

4136 * Insert or update a file record
4137 */
4138 upsertFile(file: FileRecord): void {
4139 if (!this.stmts.upsertFile) {
4140 this.stmts.upsertFile = this.db.prepare(`
4141 INSERT INTO files (path, content_hash, language, size, modified_at, indexed_at, node_count, errors, generated)
4142 VALUES (@path, @contentHash, @language, @size, @modifiedAt, @indexedAt, @nodeCount, @errors, @generated)
4143 ON CONFLICT(path) DO UPDATE SET
4144 content_hash = @contentHash,
4145 language = @language,
4146 size = @size,
4147 modified_at = @modifiedAt,
4148 indexed_at = @indexedAt,
4149 node_count = @nodeCount,
4150 errors = @errors,
4151 generated = @generated
4152 `);
4153 }
4154
4155 this.stmts.upsertFile.run({
4156 path: file.path,
4157 contentHash: file.contentHash,
4158 language: file.language,
4159 size: file.size,
4160 modifiedAt: file.modifiedAt,
4161 indexedAt: file.indexedAt,
4162 nodeCount: file.nodeCount,
4163 errors: file.errors ? JSON.stringify(file.errors) : null,
4164 // The upsert always REWRITES the flag: a file that loses its banner in an
4165 // edit must lose the flag on the next sync, not keep a stale 1.
4166 generated: file.generated ? 1 : 0,
4167 });
4168 }
4169
4170 /**
4171 * 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