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

@ -40,32 +40,32 @@ func Link(ctx context.Context, path string, args model.LinkArgs) (*model.Link, m
return res, file, nil
}
func MakeDir(ctx context.Context, path string) error {
err := makeDir(ctx, path)
func MakeDir(ctx context.Context, path string, lazyCache ...bool) error {
err := makeDir(ctx, path, lazyCache...)
if err != nil {
log.Errorf("failed make dir %s: %+v", path, err)
}
return err
}
func Move(ctx context.Context, srcPath, dstDirPath string) error {
err := move(ctx, srcPath, dstDirPath)
func Move(ctx context.Context, srcPath, dstDirPath string, lazyCache ...bool) error {
err := move(ctx, srcPath, dstDirPath, lazyCache...)
if err != nil {
log.Errorf("failed move %s to %s: %+v", srcPath, dstDirPath, err)
}
return err
}
func Copy(ctx context.Context, srcObjPath, dstDirPath string) (bool, error) {
res, err := _copy(ctx, srcObjPath, dstDirPath)
func Copy(ctx context.Context, srcObjPath, dstDirPath string, lazyCache ...bool) (bool, error) {
res, err := _copy(ctx, srcObjPath, dstDirPath, lazyCache...)
if err != nil {
log.Errorf("failed copy %s to %s: %+v", srcObjPath, dstDirPath, err)
}
return res, err
}
func Rename(ctx context.Context, srcPath, dstName string) error {
err := rename(ctx, srcPath, dstName)
func Rename(ctx context.Context, srcPath, dstName string, lazyCache ...bool) error {
err := rename(ctx, srcPath, dstName, lazyCache...)
if err != nil {
log.Errorf("failed rename %s to %s: %+v", srcPath, dstName, err)
}
@ -80,8 +80,8 @@ func Remove(ctx context.Context, path string) error {
return err
}
func PutDirectly(ctx context.Context, dstDirPath string, file *model.FileStream) error {
err := putDirectly(ctx, dstDirPath, file)
func PutDirectly(ctx context.Context, dstDirPath string, file *model.FileStream, lazyCache ...bool) error {
err := putDirectly(ctx, dstDirPath, file, lazyCache...)
if err != nil {
log.Errorf("failed put %s: %+v", dstDirPath, err)
}