feat: add task info to resp of add task api (close #5579)

This commit is contained in:
Andy Hsu
2023-12-03 14:44:20 +08:00
parent 8bdfc7ac8e
commit 026e944cbb
8 changed files with 79 additions and 50 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/alist-org/alist/v3/internal/op"
"github.com/alist-org/alist/v3/server/common"
"github.com/gin-gonic/gin"
"github.com/xhofe/tache"
)
type SetAria2Req struct {
@ -97,8 +98,9 @@ func AddOfflineDownload(c *gin.Context) {
common.ErrorResp(c, err, 403)
return
}
var tasks []tache.TaskWithInfo
for _, url := range req.Urls {
err := tool.AddURL(c, &tool.AddURLArgs{
t, err := tool.AddURL(c, &tool.AddURLArgs{
URL: url,
DstDirPath: reqPath,
Tool: req.Tool,
@ -108,6 +110,9 @@ func AddOfflineDownload(c *gin.Context) {
common.ErrorResp(c, err, 500)
return
}
tasks = append(tasks, t)
}
common.SuccessResp(c)
common.SuccessResp(c, gin.H{
"tasks": getTaskInfos(tasks),
})
}