chore: rename remove to delete

This commit is contained in:
Noah Hsu 2022-07-31 21:42:01 +08:00
parent 829ef271e3
commit c7128133d6
3 changed files with 16 additions and 15 deletions

View File

@ -2,11 +2,6 @@ package aria2
import ( import (
"fmt" "fmt"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/pkg/task"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"mime" "mime"
"os" "os"
"path" "path"
@ -14,6 +9,12 @@ import (
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/pkg/task"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
) )
type Monitor struct { type Monitor struct {
@ -107,7 +108,7 @@ func (m *Monitor) Update() (bool, error) {
} }
} }
var TransferTaskManager = task.NewTaskManager[uint64](3, func(k *uint64) { var TransferTaskManager = task.NewTaskManager(3, func(k *uint64) {
atomic.AddUint64(k, 1) atomic.AddUint64(k, 1)
}) })
@ -134,7 +135,7 @@ func (m *Monitor) Complete() error {
} }
}() }()
for _, file := range files { for _, file := range files {
TransferTaskManager.Submit(task.WithCancelCtx[uint64](&task.Task[uint64]{ TransferTaskManager.Submit(task.WithCancelCtx(&task.Task[uint64]{
Name: fmt.Sprintf("transfer %s to [%s](%s)", file.Path, storage.GetStorage().MountPath, dstDirActualPath), Name: fmt.Sprintf("transfer %s to [%s](%s)", file.Path, storage.GetStorage().MountPath, dstDirActualPath),
Func: func(tsk *task.Task[uint64]) error { Func: func(tsk *task.Task[uint64]) error {
defer wg.Done() defer wg.Done()

View File

@ -74,7 +74,7 @@ func CancelDownTask(c *gin.Context) {
} }
} }
func RemoveDownTask(c *gin.Context) { func DeleteDownTask(c *gin.Context) {
tid := c.Query("tid") tid := c.Query("tid")
if err := aria2.DownTaskManager.Remove(tid); err != nil { if err := aria2.DownTaskManager.Remove(tid); err != nil {
common.ErrorResp(c, err, 500) common.ErrorResp(c, err, 500)
@ -110,7 +110,7 @@ func CancelTransferTask(c *gin.Context) {
} }
} }
func RemoveTransferTask(c *gin.Context) { func DeleteTransferTask(c *gin.Context) {
id := c.Query("tid") id := c.Query("tid")
tid, err := strconv.ParseUint(id, 10, 64) tid, err := strconv.ParseUint(id, 10, 64)
if err != nil { if err != nil {
@ -151,7 +151,7 @@ func CancelUploadTask(c *gin.Context) {
} }
} }
func RemoveUploadTask(c *gin.Context) { func DeleteUploadTask(c *gin.Context) {
id := c.Query("tid") id := c.Query("tid")
tid, err := strconv.ParseUint(id, 10, 64) tid, err := strconv.ParseUint(id, 10, 64)
if err != nil { if err != nil {
@ -192,7 +192,7 @@ func CancelCopyTask(c *gin.Context) {
} }
} }
func RemoveCopyTask(c *gin.Context) { func DeleteCopyTask(c *gin.Context) {
id := c.Query("tid") id := c.Query("tid")
tid, err := strconv.ParseUint(id, 10, 64) tid, err := strconv.ParseUint(id, 10, 64)
if err != nil { if err != nil {

View File

@ -72,22 +72,22 @@ func admin(g *gin.RouterGroup) {
task.GET("/down/undone", handles.UndoneDownTask) task.GET("/down/undone", handles.UndoneDownTask)
task.GET("/down/done", handles.DoneDownTask) task.GET("/down/done", handles.DoneDownTask)
task.POST("/down/cancel", handles.CancelDownTask) task.POST("/down/cancel", handles.CancelDownTask)
task.POST("/down/remove", handles.RemoveDownTask) task.POST("/down/delete", handles.DeleteDownTask)
task.POST("/down/clear_done", handles.ClearDoneDownTasks) task.POST("/down/clear_done", handles.ClearDoneDownTasks)
task.GET("/transfer/undone", handles.UndoneTransferTask) task.GET("/transfer/undone", handles.UndoneTransferTask)
task.GET("/transfer/done", handles.DoneTransferTask) task.GET("/transfer/done", handles.DoneTransferTask)
task.POST("/transfer/cancel", handles.CancelTransferTask) task.POST("/transfer/cancel", handles.CancelTransferTask)
task.POST("/transfer/remove", handles.RemoveTransferTask) task.POST("/transfer/delete", handles.DeleteTransferTask)
task.POST("/transfer/clear_done", handles.ClearDoneTransferTasks) task.POST("/transfer/clear_done", handles.ClearDoneTransferTasks)
task.GET("/upload/undone", handles.UndoneUploadTask) task.GET("/upload/undone", handles.UndoneUploadTask)
task.GET("/upload/done", handles.DoneUploadTask) task.GET("/upload/done", handles.DoneUploadTask)
task.POST("/upload/cancel", handles.CancelUploadTask) task.POST("/upload/cancel", handles.CancelUploadTask)
task.POST("/upload/remove", handles.RemoveUploadTask) task.POST("/upload/delete", handles.DeleteUploadTask)
task.POST("/upload/clear_done", handles.ClearDoneUploadTasks) task.POST("/upload/clear_done", handles.ClearDoneUploadTasks)
task.GET("/copy/undone", handles.UndoneCopyTask) task.GET("/copy/undone", handles.UndoneCopyTask)
task.GET("/copy/done", handles.DoneCopyTask) task.GET("/copy/done", handles.DoneCopyTask)
task.POST("/copy/cancel", handles.CancelCopyTask) task.POST("/copy/cancel", handles.CancelCopyTask)
task.POST("/copy/remove", handles.RemoveCopyTask) task.POST("/copy/delete", handles.DeleteCopyTask)
task.POST("/copy/clear_done", handles.ClearDoneCopyTasks) task.POST("/copy/clear_done", handles.ClearDoneCopyTasks)
ms := g.Group("/message") ms := g.Group("/message")