feat: extract get function
This commit is contained in:
@ -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")
|
||||
|
Reference in New Issue
Block a user