cleanupFileRecord 清理批次中的文件记录
(batchID, fileID string)
| 43 | |
| 44 | // cleanupFileRecord 清理批次中的文件记录 |
| 45 | func (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 清理数据库中的相关记录 |
| 70 | func (h *ErrorHandler) cleanupDatabaseRecords(batchID, fileID string) error { |
no test coverage detected