mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-09-19 20:26:26 +08:00

* Enable blank issue * chore(README.md): update docs (temporally) * Update FUNDING.yml * chore: purge README.md * chore: change module name to OpenListTeam/OpenList * fix: fix link errors * chore: remove v3 in module name * fix: resolve some conficts * fix: resolve conficts * docs: update with latest file --------- Co-authored-by: ShenLin <773933146@qq.com> Co-authored-by: Hantong Chen <cxwdyx620@gmail.com> Co-authored-by: joshua <i@joshua.su> Co-authored-by: Hantong Chen <70561268+cxw620@users.noreply.github.com>
59 lines
1.9 KiB
Go
59 lines
1.9 KiB
Go
package fs
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/OpenListTeam/OpenList/internal/errs"
|
|
"github.com/OpenListTeam/OpenList/internal/model"
|
|
"github.com/OpenListTeam/OpenList/internal/op"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
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, lazyCache...)
|
|
}
|
|
|
|
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")
|
|
}
|
|
dstStorage, dstDirActualPath, err := op.GetStorageAndActualPath(dstDirPath)
|
|
if err != nil {
|
|
return errors.WithMessage(err, "failed get dst storage")
|
|
}
|
|
if srcStorage.GetStorage() != dstStorage.GetStorage() {
|
|
return errors.WithStack(errs.MoveBetweenTwoStorages)
|
|
}
|
|
return op.Move(ctx, srcStorage, srcActualPath, dstDirActualPath, lazyCache...)
|
|
}
|
|
|
|
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, lazyCache...)
|
|
}
|
|
|
|
func remove(ctx context.Context, path string) error {
|
|
storage, actualPath, err := op.GetStorageAndActualPath(path)
|
|
if err != nil {
|
|
return errors.WithMessage(err, "failed get storage")
|
|
}
|
|
return op.Remove(ctx, storage, actualPath)
|
|
}
|
|
|
|
func other(ctx context.Context, args model.FsOtherArgs) (interface{}, error) {
|
|
storage, actualPath, err := op.GetStorageAndActualPath(args.Path)
|
|
if err != nil {
|
|
return nil, errors.WithMessage(err, "failed get storage")
|
|
}
|
|
args.Path = actualPath
|
|
return op.Other(ctx, storage, args)
|
|
}
|