feat: optimize file operation interface (#2757)

* feat: optimize file operation interface

* chore: fix typo

Co-authored-by: Noah Hsu <i@nn.ci>
This commit is contained in:
foxxorcat
2022-12-20 15:02:40 +08:00
committed by GitHub
parent e2bcca2fbd
commit 62a06fa0f9
13 changed files with 330 additions and 121 deletions

View File

@ -9,15 +9,15 @@ import (
"github.com/pkg/errors"
)
func makeDir(ctx context.Context, path string) error {
func makeDir(ctx context.Context, path string, lazyCache ...bool) error {
storage, actualPath, err := op.GetStorageAndActualPath(path)
if err != nil {
return errors.WithMessage(err, "failed get storage")
}
return op.MakeDir(ctx, storage, actualPath)
return op.MakeDir(ctx, storage, actualPath, lazyCache...)
}
func move(ctx context.Context, srcPath, dstDirPath string) error {
func move(ctx context.Context, srcPath, dstDirPath string, lazyCache ...bool) error {
srcStorage, srcActualPath, err := op.GetStorageAndActualPath(srcPath)
if err != nil {
return errors.WithMessage(err, "failed get src storage")
@ -29,15 +29,15 @@ func move(ctx context.Context, srcPath, dstDirPath string) error {
if srcStorage.GetStorage() != dstStorage.GetStorage() {
return errors.WithStack(errs.MoveBetweenTwoStorages)
}
return op.Move(ctx, srcStorage, srcActualPath, dstDirActualPath)
return op.Move(ctx, srcStorage, srcActualPath, dstDirActualPath, lazyCache...)
}
func rename(ctx context.Context, srcPath, dstName string) error {
func rename(ctx context.Context, srcPath, dstName string, lazyCache ...bool) error {
storage, srcActualPath, err := op.GetStorageAndActualPath(srcPath)
if err != nil {
return errors.WithMessage(err, "failed get storage")
}
return op.Rename(ctx, storage, srcActualPath, dstName)
return op.Rename(ctx, storage, srcActualPath, dstName, lazyCache...)
}
func remove(ctx context.Context, path string) error {