fix: storage 默认 COS + indexStatus 更新 + BullMQ 跳过文件导入
All checks were successful
Deploy API Server / build (push) Successful in 36s
Deploy API Server / deploy (push) Successful in 57s

- storage.config.ts: NODE_ENV=production 默认 COS
- internal-rag.controller.ts: saveChunks 同步更新 indexStatus
- document-import.worker.ts: 文件导入跳过,留给 Python RAG Worker
- .gitignore: 添加 uploads/

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
wangdl 2026-07-04 11:59:03 +08:00
parent cd2fb53101
commit 9d35c14bc2
4 changed files with 15 additions and 6 deletions

1
.gitignore vendored
View File

@ -53,3 +53,4 @@ docs/AI回答.md
# rag-worker (migrated to own project)
rag-worker/
uploads/

View File

@ -1,7 +1,7 @@
import { registerAs } from '@nestjs/config';
export default registerAs('storage', () => ({
driver: process.env.STORAGE_DRIVER || 'local',
driver: process.env.STORAGE_DRIVER || (process.env.NODE_ENV === 'production' ? 'cos' : 'local'),
localPath: process.env.STORAGE_LOCAL_PATH || './uploads',
cos: {
secretId: process.env.STORAGE_COS_SECRET_ID || '',

View File

@ -115,7 +115,7 @@ export class InternalRagController {
const totalChars = sourceChunks.reduce((sum, c) => sum + (c.tokenCount || c.content?.length || 0), 0);
await this.prisma.knowledgeSource.updateMany({
where: { id: sourceId },
data: { textLength: totalChars, parseStatus: 'completed', updatedAt: new Date() },
data: { textLength: totalChars, parseStatus: 'completed', indexStatus: 'completed', updatedAt: new Date() },
});
}
}
@ -140,6 +140,15 @@ export class InternalRagController {
body.importId,
body.candidates || [],
);
// 更新 source 的学习状态
if (body.sourceId && body.candidates?.length > 0) {
await this.prisma.knowledgeSource.updateMany({
where: { id: body.sourceId },
data: { learningStatus: 'completed', updatedAt: new Date() },
});
}
return { success: true, count: body.candidates?.length || 0 };
}
}

View File

@ -40,10 +40,9 @@ export class DocumentImportWorker extends WorkerHost {
try {
if (!rawText) {
await this.repository.updateStatus(importId, 'completed');
await this.redis.set(`job:document-import:${importId}:status`, 'completed', 86400);
await this.redis.set(`job:document-import:${importId}:progress`, '100', 86400);
await this.redis.set(`job:document-import:${importId}:message`, '无需解析的空文件', 86400);
// 文件导入PDF/Office 等),由 Python RAG Worker 处理
// BullMQ Worker 只处理纯文本导入
this.logger.log(`Skipping file import ${importId} — delegated to Python RAG Worker`);
return;
}