Skip to content

Commit

Permalink
Call the gateway stat method from appprovider
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Sep 3, 2020
1 parent 137283e commit 6cfe5a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/appprovider-stat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Call the gateway stat method from appprovider

The appprovider service used to directly pass the stat request to the storage
provider bypassing the gateway, which resulted in errors while handling share
children as they are resolved in the gateway path.

https://github.com/cs3org/reva/pull/1140
15 changes: 2 additions & 13 deletions internal/grpc/services/gateway/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,19 @@ import (
)

func (s *svc) OpenFileInAppProvider(ctx context.Context, req *gateway.OpenFileInAppProviderRequest) (*providerpb.OpenFileInAppProviderResponse, error) {
c, err := s.find(ctx, req.Ref)
if err != nil {
if _, ok := err.(errtypes.IsNotFound); ok {
return &providerpb.OpenFileInAppProviderResponse{
Status: status.NewInternal(ctx, err, "storage provider not found"),
}, nil
}
return &providerpb.OpenFileInAppProviderResponse{
Status: status.NewInternal(ctx, err, "error finding storage provider"),
}, nil
}

accessToken, ok := tokenpkg.ContextGetToken(ctx)
if !ok || accessToken == "" {
return &providerpb.OpenFileInAppProviderResponse{
Status: status.NewUnauthenticated(ctx, err, "Access token is invalid or empty"),
Status: status.NewUnauthenticated(ctx, errors.New("Access token is invalid or empty"), ""),
}, nil
}

statReq := &provider.StatRequest{
Ref: req.Ref,
}

statRes, err := c.Stat(ctx, statReq)
statRes, err := s.Stat(ctx, statReq)
if err != nil {
return &providerpb.OpenFileInAppProviderResponse{
Status: status.NewInternal(ctx, err, "gateway: error calling Stat on the resource path for the app provider: "+req.Ref.GetPath()),
Expand Down

0 comments on commit 6cfe5a9

Please sign in to comment.