mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-21 20:18:47 +08:00
chore: export copy and upload task manager
This commit is contained in:
parent
72a76599e4
commit
73c0c0bf44
@ -13,7 +13,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var copyTaskManager = task.NewTaskManager()
|
||||
var CopyTaskManager = task.NewTaskManager()
|
||||
|
||||
// Copy if in an account, call move method
|
||||
// if not, add copy task
|
||||
@ -31,7 +31,7 @@ func Copy(ctx context.Context, account driver.Driver, srcPath, dstPath string) (
|
||||
return false, operations.Copy(ctx, account, srcActualPath, dstActualPath)
|
||||
}
|
||||
// not in an account
|
||||
copyTaskManager.Add(fmt.Sprintf("copy [%s](%s) to [%s](%s)", srcAccount.GetAccount().VirtualPath, srcActualPath, dstAccount.GetAccount().VirtualPath, dstActualPath), func(task *task.Task) error {
|
||||
CopyTaskManager.Add(fmt.Sprintf("copy [%s](%s) to [%s](%s)", srcAccount.GetAccount().VirtualPath, srcActualPath, dstAccount.GetAccount().VirtualPath, dstActualPath), func(task *task.Task) error {
|
||||
return CopyBetween2Accounts(task.Ctx, srcAccount, dstAccount, srcActualPath, dstActualPath, task.SetStatus)
|
||||
})
|
||||
return true, nil
|
||||
@ -55,12 +55,12 @@ func CopyBetween2Accounts(ctx context.Context, srcAccount, dstAccount driver.Dri
|
||||
}
|
||||
srcObjPath := stdpath.Join(srcPath, obj.GetName())
|
||||
dstObjPath := stdpath.Join(dstPath, obj.GetName())
|
||||
copyTaskManager.Add(fmt.Sprintf("copy [%s](%s) to [%s](%s)", srcAccount.GetAccount().VirtualPath, srcObjPath, dstAccount.GetAccount().VirtualPath, dstObjPath), func(task *task.Task) error {
|
||||
CopyTaskManager.Add(fmt.Sprintf("copy [%s](%s) to [%s](%s)", srcAccount.GetAccount().VirtualPath, srcObjPath, dstAccount.GetAccount().VirtualPath, dstObjPath), func(task *task.Task) error {
|
||||
return CopyBetween2Accounts(ctx, srcAccount, dstAccount, srcObjPath, dstObjPath, task.SetStatus)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
copyTaskManager.Add(fmt.Sprintf("copy [%s](%s) to [%s](%s)", srcAccount.GetAccount().VirtualPath, srcPath, dstAccount.GetAccount().VirtualPath, dstPath), func(task *task.Task) error {
|
||||
CopyTaskManager.Add(fmt.Sprintf("copy [%s](%s) to [%s](%s)", srcAccount.GetAccount().VirtualPath, srcPath, dstAccount.GetAccount().VirtualPath, dstPath), func(task *task.Task) error {
|
||||
return CopyFileBetween2Accounts(task.Ctx, srcAccount, dstAccount, srcPath, dstPath, func(percentage float64) {
|
||||
task.SetStatus(fmt.Sprintf("uploading: %2.f%", percentage))
|
||||
})
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var uploadTaskManager = task.NewTaskManager()
|
||||
var UploadTaskManager = task.NewTaskManager()
|
||||
|
||||
// Put add as a put task
|
||||
func Put(ctx context.Context, account driver.Driver, parentPath string, file model.FileStreamer) error {
|
||||
@ -18,7 +18,7 @@ func Put(ctx context.Context, account driver.Driver, parentPath string, file mod
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "failed get account")
|
||||
}
|
||||
uploadTaskManager.Add(fmt.Sprintf("upload %s to [%s](%s)", file.GetName(), account.GetAccount().VirtualPath, actualParentPath), func(task *task.Task) error {
|
||||
UploadTaskManager.Add(fmt.Sprintf("upload %s to [%s](%s)", file.GetName(), account.GetAccount().VirtualPath, actualParentPath), func(task *task.Task) error {
|
||||
return operations.Put(task.Ctx, account, actualParentPath, file, nil)
|
||||
})
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user