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

Method UpdateFileProgress

api/service/progress_storage.go:239–258  ·  view source on GitHub ↗

UpdateFileProgress 更新文件进度

(batchID, fileID string, fileUpload *FileUpload)

Source from the content-addressed store, hash-verified

237
238// UpdateFileProgress 更新文件进度
239func (s *ProgressStorage) UpdateFileProgress(batchID, fileID string, fileUpload *FileUpload) error {
240 // 更新内存缓存
241 key := fmt.Sprintf("file:%s:%s", batchID, fileID)
242 s.memoryCache.Store(key, fileUpload)
243
244 // 尝试异步更新Redis
245 if redisClient := s.ensureRedisConnection(); redisClient != nil {
246 go func() {
247 progressJSON, _ := json.Marshal(fileUpload)
248 redisKey := fmt.Sprintf("batch_upload:file:%s:%s", batchID, fileID)
249 redisClient.Set(context.Background(), redisKey, progressJSON, s.cacheTimeout)
250
251 // 更新批次最后更新时间
252 lastUpdateKey := fmt.Sprintf("batch_upload:last_update:%s", batchID)
253 redisClient.Set(context.Background(), lastUpdateKey, time.Now().UnixMilli(), s.batchTimeout)
254 }()
255 }
256
257 return nil
258}
259
260// GetFileProgress 获取文件进度
261func (s *ProgressStorage) GetFileProgress(batchID, fileID string) (*FileUpload, error) {

Callers 2

updateFileProgressMethod · 0.80

Calls 2

ensureRedisConnectionMethod · 0.95
SetMethod · 0.80

Tested by

no test coverage detected