Skip to content

Commit

Permalink
chore: fix err nil pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jul 30, 2022
1 parent 33b7d75 commit be452aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions pkg/task/task_test.go
Original file line number Diff line number Diff line change
@@ -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]{
Expand All @@ -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]{
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions server/handles/task.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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(),
}
}

Expand Down

0 comments on commit be452aa

Please sign in to comment.