Feat(remotearia2): 转存

pull/801/head
Cian John 5 years ago
parent ac20a4ca3a
commit 8c97021e8f

@ -31,6 +31,7 @@ func Init(path string) {
} else { } else {
if conf.SlaveConfig.Aria2 { if conf.SlaveConfig.Aria2 {
model.Init() model.Init()
task.Init()
aria2.Init(false) aria2.Init(false)
} }
} }

@ -152,7 +152,15 @@ func SlaveInit(isReload bool) {
Instance = client Instance = client
// monitor if !isReload {
// 从数据库中读取未完成任务,创建监控
unfinished := model.GetDownloadsByStatus(Ready, Paused, Downloading)
for i := 0; i < len(unfinished); i++ {
// 创建任务监控
NewMonitor(&unfinished[i])
}
}
} }
// MasterInit 主机初始化 // MasterInit 主机初始化

@ -3,6 +3,7 @@ package task
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"github.com/cloudreve/Cloudreve/v3/pkg/conf"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -84,6 +85,13 @@ func (job *TransferTask) GetError() *JobError {
// Do 开始执行任务 // Do 开始执行任务
func (job *TransferTask) Do() { func (job *TransferTask) Do() {
defer job.Recycle() defer job.Recycle()
if model.IsTrueVal(model.GetSettingByName("aria2_remote_enabled")) && conf.SystemConfig.Mode != "slave" {
return
}
if conf.SlaveConfig.SlaveId == 0 || model.GetIntSetting("aria2_remote_id", 0) != int(conf.SlaveConfig.SlaveId) {
return
}
// 创建文件系统 // 创建文件系统
fs, err := filesystem.NewFileSystem(job.User) fs, err := filesystem.NewFileSystem(job.User)

Loading…
Cancel
Save