perf: extract fs func and add error log
This commit is contained in:
@ -2,13 +2,12 @@ package fs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/alist-org/alist/v3/internal/driver"
|
||||
"github.com/alist-org/alist/v3/internal/errs"
|
||||
"github.com/alist-org/alist/v3/internal/operations"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func MakeDir(ctx context.Context, account driver.Driver, path string) error {
|
||||
func makeDir(ctx context.Context, path string) error {
|
||||
account, actualPath, err := operations.GetAccountAndActualPath(path)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "failed get account")
|
||||
@ -16,7 +15,7 @@ func MakeDir(ctx context.Context, account driver.Driver, path string) error {
|
||||
return operations.MakeDir(ctx, account, actualPath)
|
||||
}
|
||||
|
||||
func Move(ctx context.Context, account driver.Driver, srcPath, dstDirPath string) error {
|
||||
func move(ctx context.Context, srcPath, dstDirPath string) error {
|
||||
srcAccount, srcActualPath, err := operations.GetAccountAndActualPath(srcPath)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "failed get src account")
|
||||
@ -28,10 +27,10 @@ func Move(ctx context.Context, account driver.Driver, srcPath, dstDirPath string
|
||||
if srcAccount.GetAccount() != dstAccount.GetAccount() {
|
||||
return errors.WithStack(errs.MoveBetweenTwoAccounts)
|
||||
}
|
||||
return operations.Move(ctx, account, srcActualPath, dstDirActualPath)
|
||||
return operations.Move(ctx, srcAccount, srcActualPath, dstDirActualPath)
|
||||
}
|
||||
|
||||
func Rename(ctx context.Context, account driver.Driver, srcPath, dstName string) error {
|
||||
func rename(ctx context.Context, srcPath, dstName string) error {
|
||||
account, srcActualPath, err := operations.GetAccountAndActualPath(srcPath)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "failed get account")
|
||||
@ -39,7 +38,7 @@ func Rename(ctx context.Context, account driver.Driver, srcPath, dstName string)
|
||||
return operations.Rename(ctx, account, srcActualPath, dstName)
|
||||
}
|
||||
|
||||
func Remove(ctx context.Context, account driver.Driver, path string) error {
|
||||
func remove(ctx context.Context, path string) error {
|
||||
account, actualPath, err := operations.GetAccountAndActualPath(path)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "failed get account")
|
||||
|
Reference in New Issue
Block a user