feat(server): improve context error handle (#11342)

This commit is contained in:
darkskygit
2025-04-01 05:38:32 +00:00
parent 6ed9c33c33
commit dc67614d6d
5 changed files with 73 additions and 23 deletions

View File

@@ -217,6 +217,23 @@ export class ContextSession implements AsyncDisposable {
);
}
async saveDocRecord(
docId: string,
cb: (
record: Pick<ContextDoc, 'id' | 'status'> &
Partial<Omit<ContextDoc, 'id' | 'status'>>
) => ContextDoc
) {
const docs = [this.config.docs, ...this.config.categories.map(c => c.docs)]
.flat()
.filter(d => d.id === docId);
for (const doc of docs) {
Object.assign(doc, cb({ ...doc }));
}
await this.save();
}
async saveFileRecord(
fileId: string,
cb: (