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,8 +6,6 @@ import (
"github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/pkg/errors"
"os"
"path/filepath"
)
type Driver struct {
@ -37,23 +35,6 @@ func (d *Driver) GetAddition() driver.Additional {
return d.Addition
}
func (d *Driver) Get(ctx context.Context, path string) (driver.FileInfo, error) {
fullPath := filepath.Join(d.RootFolder, path)
if !utils.Exists(fullPath) {
return nil, errors.WithStack(driver.ErrorObjectNotFound)
}
f, err := os.Stat(fullPath)
if err != nil {
return nil, err
}
return model.File{
Name: f.Name(),
Size: uint64(f.Size()),
Modified: f.ModTime(),
IsFolder: f.IsDir(),
}, nil
}
func (d *Driver) List(ctx context.Context, path string) ([]driver.FileInfo, error) {
//TODO implement me
panic("implement me")