Fix: Node ID will be 0 in download record generated in older version

pull/1040/head
HFO4 4 years ago
parent f79508095d
commit 177c7695e3

@ -115,3 +115,13 @@ func (task *Download) GetOwner() *User {
func (download *Download) Delete() error { func (download *Download) Delete() error {
return DB.Model(download).Delete(download).Error return DB.Model(download).Delete(download).Error
} }
// GetNodeID 返回任务所属节点ID
func (task *Download) GetNodeID() uint {
// 兼容3.4版本之前生成的下载记录
if task.NodeID == 0 {
return 1
}
return task.NodeID
}

@ -37,7 +37,7 @@ func NewMonitor(task *model.Download) {
monitor := &Monitor{ monitor := &Monitor{
Task: task, Task: task,
notifier: make(chan common.StatusEvent), notifier: make(chan common.StatusEvent),
node: cluster.Default.GetNodeByID(task.NodeID), node: cluster.Default.GetNodeByID(task.GetNodeID()),
} }
if monitor.node != nil { if monitor.node != nil {
monitor.Interval = time.Duration(monitor.node.GetAria2Instance().GetConfig().Interval) * time.Second monitor.Interval = time.Duration(monitor.node.GetAria2Instance().GetConfig().Interval) * time.Second

Loading…
Cancel
Save