chore(fs): rename some variable and param
This commit is contained in:
parent
f6242d46b1
commit
72208e052a
@ -16,8 +16,8 @@ var UploadTaskManager = task.NewTaskManager[uint64, struct{}](3, func(tid *uint6
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Put add as a put task
|
// Put add as a put task
|
||||||
func Put(ctx context.Context, account driver.Driver, parentPath string, file model.FileStreamer) error {
|
func Put(ctx context.Context, account driver.Driver, dstDirPath string, file model.FileStreamer) error {
|
||||||
account, actualParentPath, err := operations.GetAccountAndActualPath(parentPath)
|
account, dstDirActualPath, err := operations.GetAccountAndActualPath(dstDirPath)
|
||||||
if account.Config().NoUpload {
|
if account.Config().NoUpload {
|
||||||
return errors.WithStack(ErrUploadNotSupported)
|
return errors.WithStack(ErrUploadNotSupported)
|
||||||
}
|
}
|
||||||
@ -25,9 +25,9 @@ func Put(ctx context.Context, account driver.Driver, parentPath string, file mod
|
|||||||
return errors.WithMessage(err, "failed get account")
|
return errors.WithMessage(err, "failed get account")
|
||||||
}
|
}
|
||||||
UploadTaskManager.Submit(task.WithCancelCtx(&task.Task[uint64, struct{}]{
|
UploadTaskManager.Submit(task.WithCancelCtx(&task.Task[uint64, struct{}]{
|
||||||
Name: fmt.Sprintf("upload %s to [%s](%s)", file.GetName(), account.GetAccount().VirtualPath, actualParentPath),
|
Name: fmt.Sprintf("upload %s to [%s](%s)", file.GetName(), account.GetAccount().VirtualPath, dstDirActualPath),
|
||||||
Func: func(task *task.Task[uint64, struct{}]) error {
|
Func: func(task *task.Task[uint64, struct{}]) error {
|
||||||
return operations.Put(task.Ctx, account, actualParentPath, file, nil)
|
return operations.Put(task.Ctx, account, dstDirActualPath, file, nil)
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
return nil
|
return nil
|
||||||
|
@ -20,14 +20,14 @@ func Move(ctx context.Context, account driver.Driver, srcPath, dstDirPath string
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "failed get src account")
|
return errors.WithMessage(err, "failed get src account")
|
||||||
}
|
}
|
||||||
dstAccount, dstActualPath, err := operations.GetAccountAndActualPath(dstDirPath)
|
dstAccount, dstDirActualPath, err := operations.GetAccountAndActualPath(dstDirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "failed get dst account")
|
return errors.WithMessage(err, "failed get dst account")
|
||||||
}
|
}
|
||||||
if srcAccount.GetAccount() != dstAccount.GetAccount() {
|
if srcAccount.GetAccount() != dstAccount.GetAccount() {
|
||||||
return errors.WithStack(ErrMoveBetweenTwoAccounts)
|
return errors.WithStack(ErrMoveBetweenTwoAccounts)
|
||||||
}
|
}
|
||||||
return operations.Move(ctx, account, srcActualPath, dstActualPath)
|
return operations.Move(ctx, account, srcActualPath, dstDirActualPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Rename(ctx context.Context, account driver.Driver, srcPath, dstName string) error {
|
func Rename(ctx context.Context, account driver.Driver, srcPath, dstName string) error {
|
||||||
|
@ -187,15 +187,15 @@ func Remove(ctx context.Context, account driver.Driver, path string) error {
|
|||||||
return account.Remove(ctx, obj)
|
return account.Remove(ctx, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Put(ctx context.Context, account driver.Driver, parentPath string, file model.FileStreamer, up driver.UpdateProgress) error {
|
func Put(ctx context.Context, account driver.Driver, dstDirPath string, file model.FileStreamer, up driver.UpdateProgress) error {
|
||||||
err := MakeDir(ctx, account, parentPath)
|
err := MakeDir(ctx, account, dstDirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessagef(err, "failed to make dir [%s]", parentPath)
|
return errors.WithMessagef(err, "failed to make dir [%s]", dstDirPath)
|
||||||
}
|
}
|
||||||
parentDir, err := Get(ctx, account, parentPath)
|
parentDir, err := Get(ctx, account, dstDirPath)
|
||||||
// this should not happen
|
// this should not happen
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessagef(err, "failed to get dir [%s]", parentPath)
|
return errors.WithMessagef(err, "failed to get dir [%s]", dstDirPath)
|
||||||
}
|
}
|
||||||
// if up is nil, set a default to prevent panic
|
// if up is nil, set a default to prevent panic
|
||||||
if up == nil {
|
if up == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user