chore: fix err nil pointer

pull/1604/head
Noah Hsu 2022-07-30 22:04:21 +08:00
parent 33b7d75d8a
commit be452aafde
2 changed files with 9 additions and 7 deletions

View File

@ -1,15 +1,16 @@
package task package task
import ( import (
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/pkg/errors"
"sync/atomic" "sync/atomic"
"testing" "testing"
"time" "time"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/pkg/errors"
) )
func TestTask_Manager(t *testing.T) { func TestTask_Manager(t *testing.T) {
tm := NewTaskManager[uint64](3, func(id *uint64) { tm := NewTaskManager(3, func(id *uint64) {
atomic.AddUint64(id, 1) atomic.AddUint64(id, 1)
}) })
id := tm.Submit(WithCancelCtx(&Task[uint64]{ id := tm.Submit(WithCancelCtx(&Task[uint64]{
@ -34,7 +35,7 @@ func TestTask_Manager(t *testing.T) {
} }
func TestTask_Cancel(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) atomic.AddUint64(id, 1)
}) })
id := tm.Submit(WithCancelCtx(&Task[uint64]{ id := tm.Submit(WithCancelCtx(&Task[uint64]{
@ -62,7 +63,7 @@ func TestTask_Cancel(t *testing.T) {
} }
func TestTask_Retry(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) atomic.AddUint64(id, 1)
}) })
num := 0 num := 0

View File

@ -1,12 +1,13 @@
package handles package handles
import ( import (
"strconv"
"github.com/alist-org/alist/v3/internal/aria2" "github.com/alist-org/alist/v3/internal/aria2"
"github.com/alist-org/alist/v3/internal/fs" "github.com/alist-org/alist/v3/internal/fs"
"github.com/alist-org/alist/v3/pkg/task" "github.com/alist-org/alist/v3/pkg/task"
"github.com/alist-org/alist/v3/server/common" "github.com/alist-org/alist/v3/server/common"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"strconv"
) )
type TaskInfo struct { type TaskInfo struct {
@ -25,7 +26,7 @@ func getTaskInfoUint(task *task.Task[uint64]) TaskInfo {
State: task.GetState(), State: task.GetState(),
Status: task.GetStatus(), Status: task.GetStatus(),
Progress: task.GetProgress(), Progress: task.GetProgress(),
Error: task.Error.Error(), Error: task.GetErrMsg(),
} }
} }