* feat: support general users view and cancel own tasks Add a creator attribute to the upload, copy and offline download tasks, so that a GENERAL task creator can view and cancel them. BREAKING CHANGE: 1. A new internal package `task` including the struct `TaskWithCreator` which embeds `tache.Base` is created, and the past dependence on `tache.Task` will all be transferred to dependence on this package. 2. The API `/admin/task` can now also be accessed via `/task`, and the old endpoint is retained to ensure compatibility with legacy automation scripts. Closes #7398 * fix(deps): update github.com/xhofe/tache to v0.1.3
This commit is contained in:
@ -1,17 +1,16 @@
|
||||
package handles
|
||||
|
||||
import (
|
||||
"github.com/xhofe/tache"
|
||||
"github.com/alist-org/alist/v3/internal/task"
|
||||
"io"
|
||||
"net/url"
|
||||
stdpath "path"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/stream"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/fs"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/stream"
|
||||
"github.com/alist-org/alist/v3/server/common"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -58,9 +57,9 @@ func FsStream(c *gin.Context) {
|
||||
Mimetype: c.GetHeader("Content-Type"),
|
||||
WebPutAsTask: asTask,
|
||||
}
|
||||
var t tache.TaskWithInfo
|
||||
var t task.TaskInfoWithCreator
|
||||
if asTask {
|
||||
t, err = fs.PutAsTask(dir, s)
|
||||
t, err = fs.PutAsTask(c, dir, s)
|
||||
} else {
|
||||
err = fs.PutDirectly(c, dir, s, true)
|
||||
}
|
||||
@ -123,12 +122,12 @@ func FsForm(c *gin.Context) {
|
||||
Mimetype: file.Header.Get("Content-Type"),
|
||||
WebPutAsTask: asTask,
|
||||
}
|
||||
var t tache.TaskWithInfo
|
||||
var t task.TaskInfoWithCreator
|
||||
if asTask {
|
||||
s.Reader = struct {
|
||||
io.Reader
|
||||
}{f}
|
||||
t, err = fs.PutAsTask(dir, &s)
|
||||
t, err = fs.PutAsTask(c, dir, &s)
|
||||
} else {
|
||||
ss, err := stream.NewSeekableStream(s, nil)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user