fix(local): return ObjectNotFound if can't find file

This commit is contained in:
Noah Hsu
2022-08-19 11:02:00 +08:00
parent 38db3508a5
commit e9927806d4
3 changed files with 13 additions and 5 deletions

View File

@ -98,6 +98,9 @@ func (d *Local) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([
func (d *Local) Get(ctx context.Context, path string) (model.Obj, error) {
f, err := os.Stat(path)
if err != nil {
if strings.Contains(err.Error(), "cannot find the file") {
return nil, errors.WithStack(errs.ObjectNotFound)
}
return nil, errors.Wrapf(err, "error while stat %s", path)
}
file := model.Object{