mirror of
https://github.com/AlistGo/alist.git
synced 2025-06-05 18:04:39 +08:00
fix: set progress to 100 when it's NaN (close #5906)
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
package handles
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/fs"
|
||||
"github.com/alist-org/alist/v3/internal/offline_download/tool"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
@ -23,12 +25,17 @@ func getTaskInfo[T tache.TaskWithInfo](task T) TaskInfo {
|
||||
if task.GetErr() != nil {
|
||||
errMsg = task.GetErr().Error()
|
||||
}
|
||||
progress := task.GetProgress()
|
||||
// if progress is NaN, set it to 100
|
||||
if math.IsNaN(progress) {
|
||||
progress = 100
|
||||
}
|
||||
return TaskInfo{
|
||||
ID: task.GetID(),
|
||||
Name: task.GetName(),
|
||||
State: task.GetState(),
|
||||
Status: task.GetStatus(),
|
||||
Progress: task.GetProgress(),
|
||||
Progress: progress,
|
||||
Error: errMsg,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user