mirror of https://github.com/cloudreve/Cloudreve
Fix: unsafe pointer while initializing unfinished aria2 task
parent
d30159579f
commit
7a6c84a115
|
@ -125,9 +125,10 @@ func Init() {
|
||||||
|
|
||||||
// 从数据库中读取未完成任务,创建监控
|
// 从数据库中读取未完成任务,创建监控
|
||||||
unfinished := model.GetDownloadsByStatus(Ready, Paused, Downloading)
|
unfinished := model.GetDownloadsByStatus(Ready, Paused, Downloading)
|
||||||
for _, task := range unfinished {
|
|
||||||
|
for i := 0; i < len(unfinished); i++ {
|
||||||
// 创建任务监控
|
// 创建任务监控
|
||||||
NewMonitor(&task)
|
NewMonitor(&unfinished[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
// DownloadListResponse 下载列表响应条目
|
// DownloadListResponse 下载列表响应条目
|
||||||
type DownloadListResponse struct {
|
type DownloadListResponse struct {
|
||||||
UpdateTime int64 `json:"update"`
|
UpdateTime int64 `json:"update"`
|
||||||
|
UpdateInterval int `json:"interval"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Status int `json:"status"`
|
Status int `json:"status"`
|
||||||
UserID uint `json:"uid"`
|
UserID uint `json:"uid"`
|
||||||
|
@ -23,6 +24,7 @@ type DownloadListResponse struct {
|
||||||
// BuildDownloadingResponse 构建正在下载的列表响应
|
// BuildDownloadingResponse 构建正在下载的列表响应
|
||||||
func BuildDownloadingResponse(tasks []model.Download) Response {
|
func BuildDownloadingResponse(tasks []model.Download) Response {
|
||||||
resp := make([]DownloadListResponse, 0, len(tasks))
|
resp := make([]DownloadListResponse, 0, len(tasks))
|
||||||
|
interval := model.GetIntSetting("aria2_interval", 10)
|
||||||
|
|
||||||
for i := 0; i < len(tasks); i++ {
|
for i := 0; i < len(tasks); i++ {
|
||||||
fileName := ""
|
fileName := ""
|
||||||
|
@ -38,6 +40,7 @@ func BuildDownloadingResponse(tasks []model.Download) Response {
|
||||||
|
|
||||||
resp = append(resp, DownloadListResponse{
|
resp = append(resp, DownloadListResponse{
|
||||||
UpdateTime: tasks[i].UpdatedAt.Unix(),
|
UpdateTime: tasks[i].UpdatedAt.Unix(),
|
||||||
|
UpdateInterval: interval,
|
||||||
Name: fileName,
|
Name: fileName,
|
||||||
Status: tasks[i].Status,
|
Status: tasks[i].Status,
|
||||||
UserID: tasks[i].UserID,
|
UserID: tasks[i].UserID,
|
||||||
|
|
Loading…
Reference in New Issue