chore: optional get func for driver

This commit is contained in:
Noah Hsu
2022-06-28 22:13:47 +08:00
parent 96380a50da
commit 505b126888
3 changed files with 22 additions and 1 deletions

View File

@ -76,6 +76,21 @@ func (d *Driver) List(ctx context.Context, dir model.Obj) ([]model.Obj, error) {
return files, nil
}
func (d *Driver) Get(ctx context.Context, path string) (model.Obj, error) {
f, err := os.Stat(path)
if err != nil {
return nil, errors.Wrapf(err, "error while stat %s", path)
}
file := model.Object{
ID: path,
Name: f.Name(),
Modified: f.ModTime(),
Size: f.Size(),
IsFolder: f.IsDir(),
}
return &file, nil
}
func (d *Driver) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {
fullPath := file.GetID()
link := model.Link{