feat: fs other api

This commit is contained in:
Noah Hsu
2022-08-03 14:14:37 +08:00
parent 2a68c3cc7b
commit 721f18a7f4
8 changed files with 86 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package fs
import (
"context"
"github.com/alist-org/alist/v3/internal/driver"
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/internal/operations"
@ -102,3 +103,11 @@ func GetStorage(path string) (driver.Driver, error) {
}
return storageDriver, nil
}
func Other(ctx context.Context, args model.FsOtherArgs) (interface{}, error) {
res, err := other(ctx, args)
if err != nil {
log.Errorf("failed remove %s: %+v", args.Path, err)
}
return res, err
}

View File

@ -2,7 +2,9 @@ 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/operations"
"github.com/pkg/errors"
)
@ -45,3 +47,12 @@ func remove(ctx context.Context, path string) error {
}
return operations.Remove(ctx, storage, actualPath)
}
func other(ctx context.Context, args model.FsOtherArgs) (interface{}, error) {
storage, actualPath, err := operations.GetStorageAndActualPath(args.Path)
if err != nil {
return nil, errors.WithMessage(err, "failed get storage")
}
args.Path = actualPath
return operations.Other(ctx, storage, args)
}