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

Method updateFileProgress

api/service/batch_upload_manager.go:387–402  ·  view source on GitHub ↗

updateFileProgress 更新文件进度(对外安全接口) 如果批次存在,会对 batch.mu 加锁后调用 updateFileProgressNoLock;否则直接持久化到 storage

(batchID, fileID string, fileUpload *FileUpload)

Source from the content-addressed store, hash-verified

385// updateFileProgress 更新文件进度(对外安全接口)
386// 如果批次存在,会对 batch.mu 加锁后调用 updateFileProgressNoLock;否则直接持久化到 storage
387func (m *BatchUploadManager) updateFileProgress(batchID, fileID string, fileUpload *FileUpload) {
388 // 先快速获取 batch 指针(使用读锁),避免长期持有全局锁
389 m.mu.RLock()
390 batch, exists := m.batches[batchID]
391 m.mu.RUnlock()
392 if !exists {
393 // 保存到存储(尽量保持幂等)
394 m.progressStorage.UpdateFileProgress(batchID, fileID, fileUpload)
395 return
396 }
397
398 // 使用 batch 的 mutex 保护对 batch.Files 的写入
399 batch.mu.Lock()
400 defer batch.mu.Unlock()
401 m.updateFileProgressNoLock(batch, fileID, fileUpload)
402}
403
404// updateBatchStatus 更新批次状态
405func (m *BatchUploadManager) updateBatchStatus(batch *BatchUpload) {

Callers 2

processUploadTaskMethod · 0.95
updateBatchProgressMethod · 0.80

Calls 3

UpdateFileProgressMethod · 0.80
UnlockMethod · 0.65

Tested by

no test coverage detected