Skip to content

Commit

Permalink
fix: set progress to 100 when it's NaN (close #5906)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jan 20, 2024
1 parent a8c900d commit 4f7761f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion internal/offline_download/aria2/aria2.go
Expand Up @@ -3,10 +3,11 @@ package aria2
import (
"context"
"fmt"
"github.com/alist-org/alist/v3/internal/errs"
"strconv"
"time"

"github.com/alist-org/alist/v3/internal/errs"

"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/offline_download/tool"
Expand Down
3 changes: 2 additions & 1 deletion internal/offline_download/tool/download.go
Expand Up @@ -2,13 +2,14 @@ package tool

import (
"fmt"
"time"

"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/errs"
"github.com/alist-org/alist/v3/internal/setting"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/xhofe/tache"
"time"
)

type DownloadTask struct {
Expand Down
9 changes: 8 additions & 1 deletion server/handles/task.go
@@ -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"
Expand All @@ -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,
}
}
Expand Down

0 comments on commit 4f7761f

Please sign in to comment.