mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-02-05 01:21:57 +08:00
Fix: unsafe pointer while initializing unfinished aria2 task
This commit is contained in:
@@ -125,9 +125,10 @@ func Init() {
|
||||
|
||||
// 从数据库中读取未完成任务,创建监控
|
||||
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 下载列表响应条目
|
||||
type DownloadListResponse struct {
|
||||
UpdateTime int64 `json:"update"`
|
||||
UpdateInterval int `json:"interval"`
|
||||
Name string `json:"name"`
|
||||
Status int `json:"status"`
|
||||
UserID uint `json:"uid"`
|
||||
@@ -23,6 +24,7 @@ type DownloadListResponse struct {
|
||||
// BuildDownloadingResponse 构建正在下载的列表响应
|
||||
func BuildDownloadingResponse(tasks []model.Download) Response {
|
||||
resp := make([]DownloadListResponse, 0, len(tasks))
|
||||
interval := model.GetIntSetting("aria2_interval", 10)
|
||||
|
||||
for i := 0; i < len(tasks); i++ {
|
||||
fileName := ""
|
||||
@@ -38,6 +40,7 @@ func BuildDownloadingResponse(tasks []model.Download) Response {
|
||||
|
||||
resp = append(resp, DownloadListResponse{
|
||||
UpdateTime: tasks[i].UpdatedAt.Unix(),
|
||||
UpdateInterval: interval,
|
||||
Name: fileName,
|
||||
Status: tasks[i].Status,
|
||||
UserID: tasks[i].UserID,
|
||||
|
||||
Reference in New Issue
Block a user