mirror of https://github.com/Xhofe/alist
				
				
				
			fix: set progress to 100 when it's NaN (close #5906)
							parent
							
								
									a8c900d09e
								
							
						
					
					
						commit
						4f7761fe2c
					
				| 
						 | 
				
			
			@ -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"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue