MCPcopy Index your code
hub / github.com/53AI/53AIHub / finalizeScanFailure

Method finalizeScanFailure

api/service/skill_library_scan.go:964–1001  ·  view source on GitHub ↗
(jobID int64, scanModel, message, payload string, retryable bool)

Source from the content-addressed store, hash-verified

962}
963
964func (s *SkillLibraryService) finalizeScanFailure(jobID int64, scanModel, message, payload string, retryable bool) error {
965 if jobID <= 0 || model.DB == nil {
966 return nil
967 }
968 logger.Warnf(context.Background(), "【技能运行】扫描失败: job_id=%d message=%s retryable=%v", jobID, message, retryable)
969
970 now := s.nowFunc().UTC().UnixMilli()
971 var job model.SkillScanJob
972 if err := model.DB.Where("id = ?", jobID).First(&job).Error; err != nil {
973 return err
974 }
975
976 status := model.SkillScanJobStatusFailed
977 retryCount := job.RetryCount
978 startedTime := job.StartedTime
979 finishedTime := now
980
981 if retryable && job.RetryCount < skillScanMaxRetry {
982 status = model.SkillScanJobStatusPending
983 retryCount = job.RetryCount + 1
984 startedTime = 0
985 finishedTime = 0
986 }
987
988 updates := map[string]interface{}{
989 "status": status,
990 "retry_count": retryCount,
991 "started_time": startedTime,
992 "finished_time": finishedTime,
993 "message": message,
994 "scan_model": scanModel,
995 "updated_time": now,
996 }
997 if payload != "" {
998 updates["scan_payload"] = payload
999 }
1000 return model.DB.Model(&model.SkillScanJob{}).Where("id = ?", jobID).Updates(updates).Error
1001}
1002
1003func (s *SkillLibraryService) recoverStaleRunningJobs(ctx context.Context) error {
1004 _ = ctx

Callers 3

executeImportJobMethod · 0.95
importSkillAtomicMethod · 0.95
executeScanJobMethod · 0.95

Calls 1

WarnfMethod · 0.80

Tested by

no test coverage detected