* Insert or update a file record
(file: FileRecord)
| 4025 | * Insert or update a file record |
| 4026 | */ |
| 4027 | upsertFile(file: FileRecord): void { |
| 4028 | if (!this.stmts.upsertFile) { |
| 4029 | this.stmts.upsertFile = this.db.prepare(` |
| 4030 | INSERT INTO files (path, content_hash, language, size, modified_at, indexed_at, node_count, errors, generated) |
| 4031 | VALUES (@path, @contentHash, @language, @size, @modifiedAt, @indexedAt, @nodeCount, @errors, @generated) |
| 4032 | ON CONFLICT(path) DO UPDATE SET |
| 4033 | content_hash = @contentHash, |
| 4034 | language = @language, |
| 4035 | size = @size, |
| 4036 | modified_at = @modifiedAt, |
| 4037 | indexed_at = @indexedAt, |
| 4038 | node_count = @nodeCount, |
| 4039 | errors = @errors, |
| 4040 | generated = @generated |
| 4041 | `); |
| 4042 | } |
| 4043 | |
| 4044 | this.stmts.upsertFile.run({ |
| 4045 | path: file.path, |
| 4046 | contentHash: file.contentHash, |
| 4047 | language: file.language, |
| 4048 | size: file.size, |
| 4049 | modifiedAt: file.modifiedAt, |
| 4050 | indexedAt: file.indexedAt, |
| 4051 | nodeCount: file.nodeCount, |
| 4052 | errors: file.errors ? JSON.stringify(file.errors) : null, |
| 4053 | // The upsert always REWRITES the flag: a file that loses its banner in an |
| 4054 | // edit must lose the flag on the next sync, not keep a stale 1. |
| 4055 | generated: file.generated ? 1 : 0, |
| 4056 | }); |
| 4057 | } |
| 4058 | |
| 4059 | /** |
| 4060 | * Which of `filePaths` the index flagged as tool-generated (schema v9+). |