mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: list tasks
This commit is contained in:
@@ -19,6 +19,33 @@ type SiteConfig struct {
|
||||
User User `json:"user"`
|
||||
}
|
||||
|
||||
type task struct {
|
||||
Status int `json:"status"`
|
||||
Type int `json:"type"`
|
||||
CreateDate string `json:"create_date"`
|
||||
Progress int `json:"progress"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
// BuildTaskList 构建任务列表响应
|
||||
func BuildTaskList(tasks []model.Task, total int) Response {
|
||||
res := make([]task, 0, len(tasks))
|
||||
for _, t := range tasks {
|
||||
res = append(res, task{
|
||||
Status: t.Status,
|
||||
Type: t.Type,
|
||||
CreateDate: t.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
Progress: t.Progress,
|
||||
Error: t.Error,
|
||||
})
|
||||
}
|
||||
|
||||
return Response{Data: map[string]interface{}{
|
||||
"total": total,
|
||||
"tasks": res,
|
||||
}}
|
||||
}
|
||||
|
||||
func checkSettingValue(setting map[string]string, key string) string {
|
||||
if v, ok := setting[key]; ok {
|
||||
return v
|
||||
|
||||
@@ -80,6 +80,7 @@ func (job *DecompressTask) Do() {
|
||||
}
|
||||
defer fs.Recycle()
|
||||
|
||||
job.TaskModel.SetProgress(DecompressingProgress)
|
||||
err = fs.Decompress(context.Background(), job.TaskProps.Src, job.TaskProps.Dst)
|
||||
if err != nil {
|
||||
job.SetErrorMsg("解压缩失败", err)
|
||||
|
||||
Reference in New Issue
Block a user