resetFileForReupload 重置文件状态为可重新上传
(batchID, fileID string)
| 111 | |
| 112 | // resetFileForReupload 重置文件状态为可重新上传 |
| 113 | func (h *ErrorHandler) resetFileForReupload(batchID, fileID string) error { |
| 114 | batch, err := h.batchManager.GetBatch(batchID) |
| 115 | if err != nil { |
| 116 | return fmt.Errorf("获取批次失败: %v", err) |
| 117 | } |
| 118 | |
| 119 | batch.mu.Lock() |
| 120 | if fileUpload, exists := batch.Files[fileID]; exists { |
| 121 | // 重置为队列状态,允许重新上传 |
| 122 | fileUpload.Status = "queued" |
| 123 | fileUpload.Error = "" |
| 124 | fileUpload.Progress = 0 |
| 125 | fileUpload.UploadedSize = 0 |
| 126 | fileUpload.DatabaseID = 0 |
| 127 | fileUpload.FileID = 0 |
| 128 | |
| 129 | // 更新进度(在持有 batch 锁的情况下安全修改) |
| 130 | // Fix: Use updateFileProgressNoLock to avoid deadlock since we already hold the lock |
| 131 | h.batchManager.updateFileProgressNoLock(batch, fileID, fileUpload) |
| 132 | |
| 133 | log.Printf("已重置文件状态为可重新上传: BatchID=%s, FileID=%s", batchID, fileID) |
| 134 | } |
| 135 | batch.mu.Unlock() |
| 136 | return nil |
| 137 | } |
| 138 | |
| 139 | // CleanupFailedBatch 清理失败的批次 |
| 140 | func (h *ErrorHandler) CleanupFailedBatch(batchID string) error { |
no test coverage detected