You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2022/09/30 04:50:02 UTC

[incubator-devlake] 01/02: fix: fix-3256

This is an automated email from the ASF dual-hosted git repository.

abeizn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit fb4d976c658fb5b5ca032095f08e492fd1f386d8
Author: Nddtfjiang <jz...@qq.com>
AuthorDate: Fri Sep 30 01:37:20 2022 +0000

    fix: fix-3256
    
    Add GetTaskById.
    
    Nddtfjiang <zh...@merico.dev>
---
 services/task.go | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/services/task.go b/services/task.go
index 43b77cf4..cec571fe 100644
--- a/services/task.go
+++ b/services/task.go
@@ -279,8 +279,15 @@ func runTaskStandalone(parentLog core.Logger, taskId uint64) errors.Error {
 	return err
 }
 
+func getTaskById(taskId uint64) *RunningTaskData {
+	runningTasks.mu.Lock()
+	defer runningTasks.mu.Unlock()
+
+	return runningTasks.tasks[taskId]
+}
+
 func updateTaskProgress(taskId uint64, progress chan core.RunningProgress) {
-	data := runningTasks.tasks[taskId]
+	data := getTaskById(taskId)
 	if data == nil {
 		return
 	}