MCPcopy Create free account
hub / github.com/53AI/53AIHub / cleanupFileRecord

Method cleanupFileRecord

api/service/error_handler.go:45–67  ·  view source on GitHub ↗

cleanupFileRecord 清理批次中的文件记录

(batchID, fileID string)

Source from the content-addressed store, hash-verified

43
44// cleanupFileRecord 清理批次中的文件记录
45func (h *ErrorHandler) cleanupFileRecord(batchID, fileID string) error {
46 batch, err := h.batchManager.GetBatch(batchID)
47 if err != nil {
48 return fmt.Errorf("获取批次失败: %v", err)
49 }
50
51 batch.mu.Lock()
52 if fileUpload, exists := batch.Files[fileID]; exists {
53 // 标记为失败状态
54 fileUpload.Status = "failed"
55 fileUpload.Error = "连接异常,请重新上传"
56 fileUpload.Progress = 0
57 fileUpload.UploadedSize = 0
58
59 // 更新进度(在持有 batch 锁的情况下安全修改)
60 // Fix: Use updateFileProgressNoLock to avoid deadlock since we already hold the lock
61 h.batchManager.updateFileProgressNoLock(batch, fileID, fileUpload)
62
63 log.Printf("已清理文件记录: BatchID=%s, FileID=%s", batchID, fileID)
64 }
65 batch.mu.Unlock()
66 return nil
67}
68
69// cleanupDatabaseRecords 清理数据库中的相关记录
70func (h *ErrorHandler) cleanupDatabaseRecords(batchID, fileID string) error {

Callers 1

Calls 5

GetBatchMethod · 0.80
ErrorfMethod · 0.80
PrintfMethod · 0.80
UnlockMethod · 0.65

Tested by

no test coverage detected