Skip to content

Commit

Permalink
feat(fs): get file object
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jun 10, 2022
1 parent 122b7ba commit 354dee6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/operations/fsutil.go → internal/fs/fsutil.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package operations
package fs

import (
"github.com/alist-org/alist/v3/internal/driver"
Expand Down
16 changes: 16 additions & 0 deletions internal/fs/get.go
Original file line number Diff line number Diff line change
@@ -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)
}
11 changes: 8 additions & 3 deletions internal/operations/fs.go → internal/fs/list.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 354dee6

Please sign in to comment.