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

Method upsertFile

src/db/queries.ts:1971–2001  ·  view source on GitHub ↗

* Insert or update a file record

(file: FileRecord)

Source from the content-addressed store, hash-verified

1969 * Insert or update a file record
1970 */
1971 upsertFile(file: FileRecord): void {
1972 if (!this.stmts.upsertFile) {
1973 this.stmts.upsertFile = this.db.prepare(`
1974 INSERT INTO files (path, content_hash, language, size, modified_at, indexed_at, node_count, errors, generated)
1975 VALUES (@path, @contentHash, @language, @size, @modifiedAt, @indexedAt, @nodeCount, @errors, @generated)
1976 ON CONFLICT(path) DO UPDATE SET
1977 content_hash = @contentHash,
1978 language = @language,
1979 size = @size,
1980 modified_at = @modifiedAt,
1981 indexed_at = @indexedAt,
1982 node_count = @nodeCount,
1983 errors = @errors,
1984 generated = @generated
1985 `);
1986 }
1987
1988 this.stmts.upsertFile.run({
1989 path: file.path,
1990 contentHash: file.contentHash,
1991 language: file.language,
1992 size: file.size,
1993 modifiedAt: file.modifiedAt,
1994 indexedAt: file.indexedAt,
1995 nodeCount: file.nodeCount,
1996 errors: file.errors ? JSON.stringify(file.errors) : null,
1997 // The upsert always REWRITES the flag: a file that loses its banner in an
1998 // edit must lose the flag on the next sync, not keep a stale 1.
1999 generated: file.generated ? 1 : 0,
2000 });
2001 }
2002
2003 /**
2004 * Which of `filePaths` the index flagged as tool-generated (schema v9+).

Callers 2

storeFileBundleMethod · 0.95
storeExtractionResultMethod · 0.80

Calls 2

prepareMethod · 0.65
runMethod · 0.65

Tested by

no test coverage detected