feat: extract get function

This commit is contained in:
Noah Hsu
2022-06-11 14:43:03 +08:00
parent ec89bb70c7
commit 77b0c69112
8 changed files with 66 additions and 24 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/alist-org/alist/v3/internal/operations"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
stdpath "path"
)
// List files
@ -37,6 +38,12 @@ func List(ctx context.Context, path string) ([]driver.FileInfo, error) {
}
func Get(ctx context.Context, path string) (driver.FileInfo, error) {
virtualFiles := operations.GetAccountVirtualFilesByPath(path)
for _, f := range virtualFiles {
if f.GetName() == stdpath.Base(path) {
return f, nil
}
}
account, actualPath, err := operations.GetAccountAndActualPath(path)
if err != nil {
return nil, errors.WithMessage(err, "failed get account")