func (s *Service) handleTaskSuccess(ctx context.Context, task *resource.Task, result *rpcscheduler.PeerResult) {
	if task.FSM.Is(resource.TaskStateSucceeded) {
		return
	}

	if err := task.FSM.Event(resource.TaskEventDownloadSucceeded); err != nil {
		task.Log.Errorf("task fsm event failed: %v", err)
		return
	}

	// Update task's resource total piece count and content length
	task.TotalPieceCount.Store(result.TotalPieceCount)
	task.ContentLength.Store(result.ContentLength)
}
// Conditions for the task to switch to the TaskStateSucceeded are:
// 1. CDN downloads the resource successfully
// 2. Dfdaemon back-to-source to download successfully
Conditions for the task to switch to the TaskStateSucceeded are:
1. CDN downloads the resource successfully
2. Dfdaemon back-to-source to download successfully
// Conditions for the task to switch to the TaskStateSucceeded are : // 1 . CDN downloads the resource successfully // 2 . Dfdaemon back - to - source to download successfully
func (s *Service) handleTaskSuccess(ctx context.Context, task *resource.Task, result *rpcscheduler.PeerResult) {
	if task.FSM.Is(resource.TaskStateSucceeded) {
		return
	}
	if err := task.FSM.Event(resource.TaskEventDownloadSucceeded); err != nil {
		task.Log.Errorf("task fsm event failed: %v", err)
		return
	}
	task.TotalPieceCount.Store(result.TotalPieceCount)
	task.ContentLength.Store(result.ContentLength)
}
func ( s * Service ) handleTaskSuccess ( ctx context . Context , task * resource . Task , result * rpcscheduler . PeerResult ) { if task . FSM . Is ( resource . TaskStateSucceeded ) { return } if err := task . FSM . Event ( resource . TaskEventDownloadSucceeded ) ; err != nil { task . Log . Errorf ( " " , err ) return } task . TotalPieceCount . Store ( result . TotalPieceCount ) task . ContentLength . Store ( result . ContentLength ) }
Conditions for the task to switch to the TaskStateSucceeded are:
1.
Conditions for the task to switch to the TaskStateSucceeded are : 1 .
// Update task's resource total piece count and content length