mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: validate / cancel task while downloading file in aria2
This commit is contained in:
@@ -22,6 +22,9 @@ type Download struct {
|
||||
Dst string `gorm:"type:text"` // 用户文件系统存储父目录路径
|
||||
UserID uint // 发起者UID
|
||||
TaskID uint // 对应的转存任务ID
|
||||
|
||||
// 关联模型
|
||||
User *User `gorm:"PRELOAD:false,association_autoupdate:false"`
|
||||
}
|
||||
|
||||
// Create 创建离线下载记录
|
||||
@@ -48,3 +51,13 @@ func GetDownloadsByStatus(status ...int) []Download {
|
||||
DB.Where("status in (?)", status).Find(&tasks)
|
||||
return tasks
|
||||
}
|
||||
|
||||
// GetOwner 获取下载任务所属用户
|
||||
func (task *Download) GetOwner() *User {
|
||||
if task.User == nil {
|
||||
if user, err := GetUserByID(task.UserID); err == nil {
|
||||
return &user
|
||||
}
|
||||
}
|
||||
return task.User
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ type Task struct {
|
||||
Type int // 任务类型
|
||||
UserID uint // 发起者UID,0表示为系统发起
|
||||
Progress int // 进度
|
||||
Error string // 错误信息
|
||||
Error string `gorm:"type:text"` // 错误信息
|
||||
Props string `gorm:"type:text"` // 任务属性
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user