File size: 1,892 Bytes
7107f0b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
package fs
import (
"context"
"github.com/alist-org/alist/v3/internal/errs"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/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)
}
|