Skip to content

Commit 66822cc

Browse files
committed
fix delete status
1 parent bd662ef commit 66822cc

File tree

6 files changed

+38
-21
lines changed

6 files changed

+38
-21
lines changed

.coignore

Whitespace-only changes.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ main.exe
2929
*.scip
3030
bin/*
3131
.roo
32-
docs/task.md
32+
docs/task.md
33+
testfiles

internal/logic/embedding_task.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,16 @@ func (l *TaskLogic) SubmitTask(req *types.IndexTaskRequest, r *http.Request) (re
150150
fileOperations = extractFileOperations(metadata)
151151
}
152152

153+
l.Logger.Infof("任务分类统计 - 添加: %d, 删除: %d, 修改: %d", len(addTasks), len(deleteTasks), len(modifyTasks))
154+
153155
// 状态修改为处理中
154156
l.svcCtx.StatusManager.UpdateFileStatus(ctx, req.RequestId,
155157
func(status *types.FileStatusResponseData) {
156158
status.Process = "processing"
157159
status.TotalProgress = 0
158160
var fileStatusItems []types.FileStatusItem
159161

162+
// 添加任务
160163
for path, _ := range files {
161164
fileStatusItem := types.FileStatusItem{
162165
Path: path, // 使用当前处理的文件路径,而不是codebasePath
@@ -166,6 +169,16 @@ func (l *TaskLogic) SubmitTask(req *types.IndexTaskRequest, r *http.Request) (re
166169
fileStatusItems = append(fileStatusItems, fileStatusItem)
167170
}
168171

172+
// 删除任务
173+
for path, op := range fileOperations {
174+
fileStatusItem := types.FileStatusItem{
175+
Path: path, // 使用当前处理的文件路径,而不是codebasePath
176+
Status: "processing",
177+
Operate: op,
178+
}
179+
fileStatusItems = append(fileStatusItems, fileStatusItem)
180+
}
181+
169182
status.FileList = fileStatusItems
170183
l.Logger.Infof("初始化状态: - RequestId: %s , %v", req.RequestId, status.FileList)
171184
})
@@ -204,7 +217,7 @@ func (l *TaskLogic) SubmitTask(req *types.IndexTaskRequest, r *http.Request) (re
204217
l.Logger.Infof("文件处理个数为0,直接标识完成状态 - RequestId: %s", req.RequestId)
205218

206219
l.svcCtx.StatusManager.UpdateFileStatus(ctx, req.RequestId, func(status *types.FileStatusResponseData) {
207-
status.Process = "processing"
220+
status.Process = "completed"
208221
status.TotalProgress = 100
209222

210223
for i, _ := range status.FileList {
@@ -411,7 +424,6 @@ func (l *TaskLogic) processShenmaSyncFile(zipFile *zip.File, shenmaSyncFiles map
411424
// 额外输出到控制台,确保用户能看到
412425
fmt.Printf("=== .shenma_sync文件内容 ===\n")
413426
fmt.Printf("文件名: %s\n", zipFile.Name)
414-
fmt.Printf("内容长度: %d 字节\n", len(content))
415427
fmt.Printf("内容:\n%s\n", string(content))
416428
fmt.Printf("========================\n\n")
417429

internal/store/redis/status_manager.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ func (sm *StatusManager) parseTaskInfo(key string, status types.FileStatusRespon
227227
StartTime: startTime,
228228
LastUpdateTime: lastUpdateTime,
229229
EstimatedCompletionTime: estimatedCompletionTime,
230+
FileList: status.FileList,
230231
}, nil
231232
}
232233

@@ -381,6 +382,7 @@ func (sm *StatusManager) parseCompletedTaskInfo(key string, status types.FileSta
381382
SuccessCount: successCount,
382383
FailedCount: failedCount,
383384
SuccessRate: successRate,
385+
FileList: status.FileList,
384386
}, nil
385387
}
386388

internal/types/completed_tasks.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ import "time"
44

55
// CompletedTaskInfo 已完成任务信息
66
type CompletedTaskInfo struct {
7-
TaskId string `json:"taskId"` // 任务ID
8-
ClientId string `json:"clientId"` // 客户端ID
9-
Status string `json:"status"` // 任务状态
10-
Process string `json:"process"` // 处理进程
11-
TotalProgress int `json:"totalProgress"` // 总进度
12-
CompletedTime time.Time `json:"completedTime"` // 完成时间
13-
FileCount int `json:"fileCount"` // 文件总数
14-
SuccessCount int `json:"successCount"` // 成功文件数
15-
FailedCount int `json:"failedCount"` // 失败文件数
16-
SuccessRate float64 `json:"successRate"` // 成功率
7+
TaskId string `json:"taskId"` // 任务ID
8+
ClientId string `json:"clientId"` // 客户端ID
9+
Status string `json:"status"` // 任务状态
10+
Process string `json:"process"` // 处理进程
11+
TotalProgress int `json:"totalProgress"` // 总进度
12+
CompletedTime time.Time `json:"completedTime"` // 完成时间
13+
FileCount int `json:"fileCount"` // 文件总数
14+
SuccessCount int `json:"successCount"` // 成功文件数
15+
FailedCount int `json:"failedCount"` // 失败文件数
16+
SuccessRate float64 `json:"successRate"` // 成功率
17+
FileList []FileStatusItem `json:"fileList"` // 文件列表
1718
}
1819

1920
// CompletedTasksResponse 已完成任务查询响应

internal/types/running_tasks.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import "time"
44

55
// RunningTaskInfo 运行中任务信息
66
type RunningTaskInfo struct {
7-
TaskId string `json:"taskId"` // 任务ID
8-
ClientId string `json:"clientId"` // 客户端ID
9-
Status string `json:"status"` // 任务状态
10-
Process string `json:"process"` // 处理进程
11-
TotalProgress int `json:"totalProgress"` // 总进度
12-
StartTime time.Time `json:"startTime"` // 开始时间
13-
LastUpdateTime time.Time `json:"lastUpdateTime"` // 最后更新时间
14-
EstimatedCompletionTime *time.Time `json:"estimatedCompletionTime,omitempty"` // 预计完成时间
7+
TaskId string `json:"taskId"` // 任务ID
8+
ClientId string `json:"clientId"` // 客户端ID
9+
Status string `json:"status"` // 任务状态
10+
Process string `json:"process"` // 处理进程
11+
TotalProgress int `json:"totalProgress"` // 总进度
12+
StartTime time.Time `json:"startTime"` // 开始时间
13+
LastUpdateTime time.Time `json:"lastUpdateTime"` // 最后更新时间
14+
EstimatedCompletionTime *time.Time `json:"estimatedCompletionTime,omitempty"` // 预计完成时间
15+
FileList []FileStatusItem `json:"fileList"` // 文件列表
1516
}
1617

1718
// RunningTasksResponse 运行中任务查询响应

0 commit comments

Comments
 (0)