mirror of https://github.com/Xhofe/alist
feat(fs): get file object
parent
122b7baa73
commit
354dee67dc
|
@ -1,4 +1,4 @@
|
|||
package operations
|
||||
package fs
|
||||
|
||||
import (
|
||||
"github.com/alist-org/alist/v3/internal/driver"
|
|
@ -0,0 +1,16 @@
|
|||
package fs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/alist-org/alist/v3/internal/driver"
|
||||
"github.com/alist-org/alist/v3/internal/operations"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func Get(ctx context.Context, path string) (driver.FileInfo, error) {
|
||||
account, actualPath, err := operations.GetAccountAndActualPath(path)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "failed get account")
|
||||
}
|
||||
return account.File(ctx, actualPath)
|
||||
}
|
|
@ -1,15 +1,20 @@
|
|||
package operations
|
||||
package fs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/alist-org/alist/v3/internal/driver"
|
||||
"github.com/alist-org/alist/v3/internal/operations"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// List files
|
||||
// TODO: hide
|
||||
// TODO: sort
|
||||
// TODO: cache, and prevent cache breakdown
|
||||
func List(ctx context.Context, path string) ([]driver.FileInfo, error) {
|
||||
account, actualPath, err := GetAccountAndActualPath(path)
|
||||
virtualFiles := GetAccountVirtualFilesByPath(path)
|
||||
account, actualPath, err := operations.GetAccountAndActualPath(path)
|
||||
virtualFiles := operations.GetAccountVirtualFilesByPath(path)
|
||||
if err != nil {
|
||||
if len(virtualFiles) != 0 {
|
||||
return virtualFiles, nil
|
Loading…
Reference in New Issue