From be452aafde910809dd470156140a9947022100c9 Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Sat, 30 Jul 2022 22:04:21 +0800 Subject: [PATCH] chore: fix err nil pointer --- pkg/task/task_test.go | 11 ++++++----- server/handles/task.go | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/task/task_test.go b/pkg/task/task_test.go index 607218b1a0d..42236ca8a40 100644 --- a/pkg/task/task_test.go +++ b/pkg/task/task_test.go @@ -1,15 +1,16 @@ package task import ( - "github.com/alist-org/alist/v3/pkg/utils" - "github.com/pkg/errors" "sync/atomic" "testing" "time" + + "github.com/alist-org/alist/v3/pkg/utils" + "github.com/pkg/errors" ) func TestTask_Manager(t *testing.T) { - tm := NewTaskManager[uint64](3, func(id *uint64) { + tm := NewTaskManager(3, func(id *uint64) { atomic.AddUint64(id, 1) }) id := tm.Submit(WithCancelCtx(&Task[uint64]{ @@ -34,7 +35,7 @@ func TestTask_Manager(t *testing.T) { } func TestTask_Cancel(t *testing.T) { - tm := NewTaskManager[uint64](3, func(id *uint64) { + tm := NewTaskManager(3, func(id *uint64) { atomic.AddUint64(id, 1) }) id := tm.Submit(WithCancelCtx(&Task[uint64]{ @@ -62,7 +63,7 @@ func TestTask_Cancel(t *testing.T) { } func TestTask_Retry(t *testing.T) { - tm := NewTaskManager[uint64](3, func(id *uint64) { + tm := NewTaskManager(3, func(id *uint64) { atomic.AddUint64(id, 1) }) num := 0 diff --git a/server/handles/task.go b/server/handles/task.go index 666d8a2b6e5..18b3c0ac50f 100644 --- a/server/handles/task.go +++ b/server/handles/task.go @@ -1,12 +1,13 @@ package handles import ( + "strconv" + "github.com/alist-org/alist/v3/internal/aria2" "github.com/alist-org/alist/v3/internal/fs" "github.com/alist-org/alist/v3/pkg/task" "github.com/alist-org/alist/v3/server/common" "github.com/gin-gonic/gin" - "strconv" ) type TaskInfo struct { @@ -25,7 +26,7 @@ func getTaskInfoUint(task *task.Task[uint64]) TaskInfo { State: task.GetState(), Status: task.GetStatus(), Progress: task.GetProgress(), - Error: task.Error.Error(), + Error: task.GetErrMsg(), } }